Skip to content

service: HealthCheckingLoadBalancerFactory using its own attribute - #6704

Merged
creamsoup merged 4 commits into
grpc:masterfrom
creamsoup:migrate_hclb
Feb 29, 2020
Merged

service: HealthCheckingLoadBalancerFactory using its own attribute#6704
creamsoup merged 4 commits into
grpc:masterfrom
creamsoup:migrate_hclb

Conversation

@creamsoup

@creamsoup creamsoup commented Feb 13, 2020

Copy link
Copy Markdown
Contributor

prerequisite for removing NAME_RESOLVERSERVICE_CONFIG attribute.


@Internal
@ResolutionResultAttr
public static final Attributes.Key<Map<String, ?>> RESOLUTION_RESULT_ATTR_HEALTH_CHECKING_CONFIG =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be in GrpcAttributes.java

@creamsoup creamsoup Feb 13, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in current world yes, but the Attributes is actually API not an implementation of io.grpc.api (core). for example, if user depends on io.grpc.services 1.n.x, io.grpc.api 1.n.x and io.grpc.core 1.(n-1).x. it won't work. because, we are using the attributes as API. so, going forward the shared attributes should be in the api not in core. we are trying to fix this issue slowly from this change.
NOTE: this specific change requires latest version of all 3 artifacts
@ejona86 can explain it better (or correct my understanding).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

io.grpc.internal should be considered convenience. Easiest test to check if it is convenience is to ask if it would work if each user of it shaded it. This attribute is used cross-module, between a transport/core and a load balancer, so it should not be in internal.

The same would be true of GrpcAttributes.ATTR_LB_PROVIDED_BACKEND. ATTR_CLIENT_EAG_ATTRS is a hack that maybe should be moved out as well, but maybe we want to replace it with something else. So that just leaves ATTR_SECURITY_LEVEL, which is sort of fine, but could be done in a more explicit way; it was sort of a lazy solution to pass data out of transports.

So in general, GrpcAttributes is a code smell and any new attributes added there should be treated with suspicion.

@SuppressWarnings("unchecked")
Map<String, ?> verifiedRawServiceConfig = (Map<String, ?>) rawServiceConfig.getConfig();
Map<String, ?> healthCheckedService =
ServiceConfigUtil.getHealthCheckedService(verifiedRawServiceConfig);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't look right. I think we want this to be in ManangedChannelImpl so that it applies to all name resolvers.

What made me notice this is that RESOLUTION_RESULT_ATTR_HEALTH_CHECKING_CONFIG was put in NameResolver and not LoadBalancer. I expected it in LoadBalancer and for the NameResolver to be ignorant of it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to LoadBalancer, PTAL

@voidzcy voidzcy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Btw, would you need a test case in ManagedChannelImpl to cover HealthCheckingCoonfig gets parsed and propagated?

@creamsoup

creamsoup commented Feb 28, 2020

Copy link
Copy Markdown
Contributor Author

Btw, would you need a test case in ManagedChannelImpl to cover HealthCheckingCoonfig gets parsed and propagated?

yes, now it is testable. i'll create some.

I wish i could test the attribute, but ManagedChannelImplTest is faking that part.

private static Map<String, Object> parseConfig(String json) throws Exception {
return (Map<String, Object>) JsonParser.parse(json);
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: new line.

Btw, why not just put in ManagedChannelImplTest.java?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

because this test is only testing ManagedChannelServiceConfig. i would love to verify the MCI sets the new Attribute or not but the MCI test is faking that particular code path.

@ejona86 ejona86 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think ideally we would just save the health name String (basically by calling ServiceConfigUtil.getHealthCheckedServiceName()) within ManagedChannelImpl, but this is a good step in the right direction and fixes the immediate problem.

@creamsoup
creamsoup merged commit 2162ad0 into grpc:master Feb 29, 2020
@creamsoup
creamsoup deleted the migrate_hclb branch February 29, 2020 01:11
dfawley pushed a commit to dfawley/grpc-java that referenced this pull request Jan 15, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants