Skip to content
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: GKE client to cloudrun server test #154

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

eshitachandwani
Copy link
Member

Tests the case where the client is in GKE and the server is running in cloudrun. Verifies that 100 RPCs reach the server correctly and return with the correct response.

@eshitachandwani eshitachandwani requested a review from a team as a code owner February 26, 2025 20:11
# Help.
./run.sh ./bin/run_test_server_cloud_run.py --help

# Run modes.
Copy link

@kannanjgithub kannanjgithub Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these since we are not taking any args. Only have a single run mode without any arg.
Rename the file was well to have cloud_run instead of c6n.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,102 @@
# Copyright 2024 gRPC authors.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -651,6 +736,8 @@ def _execute( # pylint: disable=arguments-differ
)
request.headers[DEBUG_HEADER_KEY] = self.gfe_debug_header
request.add_response_callback(self._log_debug_header)
logger.info("Executing request: %s", request)
logger.info(request.to_json())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this logging, it seems not really related to our changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment on lines 268 to 269
logger.info("backend service protocol")
logger.info(self.backend_service_protocol)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this logging.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 36 to 41
MESH_NAME = "grpc-mesh"
SERVER_TLS_POLICY_NAME = "server-tls-policy"
CLIENT_TLS_POLICY_NAME = "client-tls-policy"
AUTHZ_POLICY_NAME = "authz-policy"
ENDPOINT_POLICY = "endpoint-policy"
CERTIFICATE_PROVIDER_INSTANCE = "google_cloud_private_spiffe"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem to be unused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 77 to 81
# Managed resources
self.server_tls_policy: Optional[ServerTlsPolicy] = None
self.client_tls_policy: Optional[ClientTlsPolicy] = None
self.authz_policy: Optional[AuthorizationPolicy] = None
self.endpoint_policy: Optional[EndpointPolicy] = None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't need these policies for the cloud run CSM gRPC testcase, but only for the SPIFFE test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

new_backends.append(new_backend)

# self.backends.update(new_backends)
backend_service = self.backend_service

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly use self.backend_service

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

raise ValueError("service_name cannot be empty or None")
if not image_name:
raise ValueError("image_name cannot be empty or None")
service_name = service_name[:49]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 49? Please consider add a comment for this magic number.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was something done by Sourabh. Let me confirm with him.

Copy link

@kannanjgithub kannanjgithub Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you figure this out by printing what is that first 48 characters being extracted? If there is some delimiter at index 49 we can use that to split.

self.compute.backend_service_patch_backends(
self.backend_service,
backends,
is_cloudrun=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ensure that 'Cloud Run' is treated as two separate words consistently throughout?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -59,6 +62,11 @@ def gcp_api_manager():
return gcp.api.GcpApiManager()


@functools.cache
def c6n_api_manager():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ensure that we are not using c6n anywhere ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -0,0 +1,141 @@
# Copyright 2022 gRPC authors.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

)
return neg

def assertXdsConfigExists(self, test_client: XdsTestClient):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the only difference w.r.t. the method of the same name in XdsKubernetesBaseTestCase is the assertion for the endpoint_config, can we add a boolean parameter to indicate cloud run and have the different assertion based on that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the benefit of doing that ? As far as I could see we overwrite the functions we can to change from the base class.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid repetition of logic. If the assertion for Xds config for GKE case and cloud run case was vastly different, it would make more sense to override it completely but here the only difference is that in the GKE case we assert for endpoint_config but not in the case of cloud run Xds config.
There may be an argument that the base class is polluted with subclass logic, and it is valid. For that I have this new suggestion: let the base class assertXdsConfig only validate LDS, RDS and CDS, and then call another method mayBeAssertEdsConfig(seen) . Base class method will do the EDS config assertions but the cloud run subclass override of mayBeAssertEdsConfig will just be a no-op (pass statement).

@@ -1395,3 +1400,177 @@ def debug_cert(cert):
return "missing"
sha1 = hashlib.sha1(cert)
return f"sha1={sha1.hexdigest()}, len={len(cert)}"


class CloudRunXdsKubernetesTestCase(RegularXdsKubernetesTestCase):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extend from SecurityXdsKubernetesTestCase and create the client using the existing method StartSecureTestClient? If we do that we can also maintain a single client deployment yaml with the new changes for cloud run test added in the same yaml.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to make it extend SecurityXdsKubernetesTestCase , but I dont understand the part about using the same YAML , we are still using the same yaml as client.deployement.yaml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can ignore the part of my comment where I wrongly thought there was an additional yaml created for cloud run.

)
# TODO(sergiitk): dataclass
)
except Exception as e:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try catch only creates redundant log as the caller site already has it.

@@ -41,6 +41,9 @@ spec:
- "--qps=${qps}"
- "--rpc=${rpc}"
- "--metadata=${metadata}"
% if secure_mode:
- "--secure_mode=${secure_mode}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this change. --secure_mode=false/true is always passed here

Copy link

@kannanjgithub kannanjgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants