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

xds: Parsing xDS Cluster Metadata #11741

Merged
merged 6 commits into from
Jan 7, 2025

Conversation

shivaspeaks
Copy link
Member

@shivaspeaks shivaspeaks commented Dec 11, 2024

Add Support for Audience Metadata Parsing in xDS Cluster Resource

@shivaspeaks shivaspeaks requested a review from ejona86 December 11, 2024 11:50
@shivaspeaks shivaspeaks requested a review from ejona86 December 13, 2024 09:00
@shivaspeaks
Copy link
Member Author

Note: I will add unit tests in the next commit after finalizing on main code. Please react on this comment (👍) if this looks good, and then I will proceed with unit tests.

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Seems ready for tests

xds/src/main/java/io/grpc/xds/XdsClusterResource.java Outdated Show resolved Hide resolved
@shivaspeaks shivaspeaks requested a review from ejona86 December 19, 2024 06:42
@ejona86
Copy link
Member

ejona86 commented Dec 19, 2024

@danielzhaotongliu

return INSTANCE;
}

ClusterMetadataValueParser findParser(String typeUrl) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should have a @Nullable annotation as the underlying get(key) method could return null if the key (typeUrl) is not found in the HashMap

Copy link
Member

Choose a reason for hiding this comment

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

@Nullable is not required in grpc-java. It is inconsistent, and without a null checker, it is nothing more than documentation.

xds/src/main/java/io/grpc/xds/GcpAuthenticationFilter.java Outdated Show resolved Hide resolved
.build();

Struct filterMetadata = Struct.newBuilder()
.putFields("key1", Value.newBuilder().setStringValue("value1").build())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we craft other types of Values in the test cases to excersise all branches of the convertValue method above (e.g. LIST_VALUE, BOOL_VALUE, etc.)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't feel like doing so right now, as we are concerned only about Audience here which will always be StringValue. We definitely need to add tests as and when the usage grows. Adding more tests on different value types right now will be purely based on assumption.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we are concerned only about Audience here which will always be StringValue ... Adding more tests on different value types right now will be purely based on assumption.

If we not using the other cases and only using STRING_VALUE, then we should delete the other unused branches in convertValue until they are needed. This would keep the code and tests focused.

Copy link
Member

Choose a reason for hiding this comment

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

Independent of the plan, I suspect we shouldn't do that sort of testing here. It can be part of a separate ProtobufJsonConverterTest.

Deleting the branches in ProtobufJsonConverter doesn't seem to benefit anyone.

Copy link
Member

Choose a reason for hiding this comment

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

We are not only concerned with Audience here. You are doing two things: 1) adding the metadata infrastructure and 2) supporting Audience. Properly handling the JSON is part of (1). We should add a ProtobufJsonConverterTest to fully-cover the converter. This should be very easy.

Copy link
Collaborator

@danielzhaotongliu danielzhaotongliu left a comment

Choose a reason for hiding this comment

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

nit: the PR title should start with xds: (module name) as it is all xDS related changes per convertValue per https://github.com/grpc/grpc-java/blob/master/CONTRIBUTING.md#guidelines-for-pull-requests

.build();

Struct filterMetadata = Struct.newBuilder()
.putFields("key1", Value.newBuilder().setStringValue("value1").build())
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are concerned only about Audience here which will always be StringValue ... Adding more tests on different value types right now will be purely based on assumption.

If we not using the other cases and only using STRING_VALUE, then we should delete the other unused branches in convertValue until they are needed. This would keep the code and tests focused.

@shivaspeaks shivaspeaks changed the title Parsing xDS Cluster Metadata xds: Parsing xDS Cluster Metadata Dec 23, 2024
@shivaspeaks shivaspeaks requested a review from ejona86 December 23, 2024 08:23
* <p>This class maintains a mapping of type URLs to {@link ClusterMetadataValueParser} instances,
* allowing for the parsing of different metadata types.
*/
final class ClusterMetadataRegistry {
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't have "Cluster" in its name. It is for all xds metadata.

@shivaspeaks shivaspeaks merged commit 1edc4d8 into grpc:master Jan 7, 2025
14 checks passed
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.

3 participants