-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cloudrun server test #150
base: main
Are you sure you want to change the base?
cloudrun server test #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick review, please address. Then I'll follow up with a more thorough review.
from typing import Optional | ||
|
||
import framework | ||
from framework.infrastructure import c6n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is c6n
this a common abbreviation? If no, we should call it cloud_run.
@@ -0,0 +1,66 @@ | |||
# Copyright 2020 gRPC authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please bump copyrights of the new files to 2025
# "balancingMode": "CONNECTION", | ||
# "maxRatePerEndpoint": max_rate_per_endpoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please parametrize this, so it doesn't affect current tests
@@ -158,7 +158,7 @@ def create_backend_service_traffic_director( | |||
body = { | |||
"name": name, | |||
"loadBalancingScheme": "INTERNAL_SELF_MANAGED", # Traffic Director | |||
"healthChecks": [health_check.url], | |||
# "healthChecks": [health_check.url], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please parametrize this, so it doesn't affect current tests
print(neg) | ||
return neg | ||
|
||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too broad for a create_* function.
.execute() | ||
) | ||
neg = self.get_serverless_network_endpoint_group(name, region) | ||
print(neg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use logger
- name: grpc-td-conf | ||
emptyDir: | ||
medium: Memory | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add nl at EOF
@@ -36,7 +36,7 @@ spec: | |||
## driver waiting for the container to start. | |||
failureThreshold: 1000 | |||
args: | |||
- "--server=${server_target}" | |||
- "--server=psm-grpc-server:8080" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will break existing tests
GCR_TESTING: Final[ | ||
str | ||
] = "us-docker.pkg.dev/grpc-testing/trafficdirector/td-grpc-bootstrap" | ||
GCR_TESTING: Final[str] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably using more a more recent version of black. Please reinstall packages with pip install -r requirements-dev.txt
, and revert unrelated code changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more comments.
@@ -1282,3 +1285,125 @@ def _get_certificate_provider(cls): | |||
"pluginInstance": cls.CERTIFICATE_PROVIDER_INSTANCE, | |||
}, | |||
} | |||
|
|||
|
|||
class TrafficDirectorCloudRunManager(TrafficDirectorAppNetManager): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move to a separate file, similar to traffic_director_gamma.py
spec: | ||
containers: | ||
- name: psm-grpc-client | ||
image: docker.io/grpc/xds-example-cpp-client:v1.69.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem like you removed most variables from the template (image, bootstrap image, deployment name, etc). Is this template supposed to be temporary? I'd highly prefer if we parametrized regular client.deployment.yaml
instead,
class BaselineTest(xds_k8s_testcase.CloudRunXdsKubernetesTestCase): | ||
def test_traffic_director_grpc_setup(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please choose appropriate names for the test class and test case
@@ -199,6 +199,12 @@ | |||
help="Enable support for Dual Stack resources to the framework.", | |||
) | |||
|
|||
REGION = flags.DEFINE_string( | |||
"region", | |||
default="us-central1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default="us-central1", | |
default=None, |
@@ -33,6 +33,18 @@ | |||
help="Traffic Director gRPC Bootstrap Docker image", | |||
) | |||
|
|||
CLOUDRUN_SERVER_IMAGE = flags.DEFINE_string( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need separate images? I thought we'll be using our regular test server / test client.
|
||
def create_grpc_route(self, src_host: str, src_port: int): | ||
hostname = src_host | ||
route_name = f"{self.resource_prefix}-grpc-route-{self.resource_suffix}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this different from TrafficDirectorAppNetManager.create_grpc_route
? If so, please add a note explaining how
|
||
https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity | ||
""" | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks the same as KubernetesBaseRunner._get_workload_identity_member_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't run the cloud run service as a workload in the CSM tests (and I don't see this method called from anywhere). Only for SPIFFE tests the calling cloud run service will join the workload identity pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Looks like there are other methods in this class that are copy-pasted from KubernetesBaseRunner
, but never called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move to gcp/
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CloudRunApiManager: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider extending GcpStandardCloudApiResource
|
||
try: | ||
operation = self._client.create_service(request=request) | ||
self._service = operation.result(timeout=300) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that operation is not guaranteed to succeed on the first try. Instead, use GcpProjectApiResource.wait_for_operation
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
Run xDS Test Client on Kubernetes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the comment.
self.run_history = collections.deque() | ||
|
||
# Persistent across many runs. | ||
self.run_history = collections.deque() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated twice.
self.service_name, self.image_name | ||
) | ||
|
||
def _start_completed(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not called from anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. @sourabhsinghs - this should be called from CloudRunServerRunner
, once you finished the deployment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you also want to call _stop
from at the end of cleanup
) | ||
|
||
self._reset_state() | ||
self.time_start_requested = dt.datetime.now(tz=dt.timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add tz=dt.timezone.utc
everywhere when copying from KubernetesBaseRunner
? We intentionally assume local timezone elsewhere. We even log it at the beginning
logger.info("Logs timezone: %s", time.localtime().tm_zone)
"""Deploys and manages the xDS Test Server on Cloud Run.""" | ||
logger.info(self.service_name) | ||
logger.info(self.image_name) | ||
deployed_service_url = self.cloudrun_api_manager.deploy_service( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to use the baseclass' run method which also has the cloudrun_api_manager.deploy_service call?
ports=[ | ||
run_v2.ContainerPort( | ||
name="http1", | ||
container_port=50051, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be getting the value from self.server_xds_port?
return self._start_test_client(test_server.xds_uri, **kwargs) | ||
|
||
def backend_service_add_serverless_neg_backends(self): | ||
logger.info("Creating serverless NEG") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cloud run service name needs to be added to the NEG
gcloud compute network-endpoint-groups create destination-neg --region=us-central1 --network-endpoint-type=serverless --cloud-run-service=$DEST_SERVICE
] = GcpResourceManager().affinity_backend_service() | ||
path_matcher["defaultService"] = ( | ||
GcpResourceManager().affinity_backend_service() | ||
) | ||
return host_rule, path_matcher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Only whitespace diffs in this file, revert.
No description provided.