-
Notifications
You must be signed in to change notification settings - Fork 4k
xds: migrate xDS resolver to use XdsClient APIs for watching individual LDS/RDS resources #7469
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: migrate xDS resolver to use XdsClient APIs for watching individual LDS/RDS resources #7469
Conversation
…ource individually.
45c2e0c to
f95e61c
Compare
…xds_resolver_to_use_watch_lds_rds_individually
| .setServiceConfig(emptyServiceConfig) | ||
| // let channel take action for no config selector | ||
| .build(); | ||
| private boolean started; |
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 don't think this flag is necessary. It's immediately true once instantiated.
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.
Ah, this was for the same reason as the rdsWatcher != this check for RDS watcher. When there is multi-threading involved, it is possible that a callback was scheduled (to be executed later) while this resolver is being shut down. Then when the callback is invoked, it should be ignored.
Without this flag, it would do the similar check resolveState != this.
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 would recommend add the checks when you are really implementing the race handling, and review them together. This is really based on assumptions of future implementation which I cannot see the whole picture.
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.
Okay, eliminated flags used for racing cases for now.
| } | ||
|
|
||
| private void start() { | ||
| if (started) { |
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 believe start() is only called right after instantiation and won't be called twice.
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 problem for not using start()/stop() is that the LdsResourceWatcher implementation class will not be self-contained. It would be something like
class XdsNameResolver {
private LdsResourceWatcher ldsWatcher;
@Override
public void start(Listener2 listener) {
...
ldsWatcher = new LdsResourceWatcherImpl();
xdsClient.watchLdsResource(authority, ldsWatcher);
}
@Override
public void shutdown() {
...
if (xdsClient != null) {
if (ldsWatcher != null) {
xdsClient.cancelLdsResourceWatch(authority, ldsWatcher);
}
...
}
...
}
}I prefer the existing approach as it encapsulate things better. What do you think?
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 was not saying not to use start()/stop(). It was about checking the started flag.
|
|
||
| @Override | ||
| public void onChanged(RdsUpdate update) { | ||
| if (this != rdsWatcher) { |
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.
Let's not do this now based on assumptions on future XdsClient implementation. It's not clear how race is handled by XdsClient yet.
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.
Eliminated. Will reconsider in next steps.
| xdsClient.cancelLdsResourceWatch(authority, this); | ||
| cleanUpRdsWatcher(); |
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.
Should they be cleaned up in a FILO order?
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.
It shouldn't matter. But sure, swapped.
| } | ||
|
|
||
| // https://github.com/google/error-prone/issues/1767 | ||
| @SuppressWarnings("ModifyCollectionInEnhancedForLoop") |
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 wonder where the error-prone warning was coming from in the old code.
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.
It's for modifying ConcurrentMap clusterRefs in the loop. Not sure how that was triggered. But now, seems it doesn't trigger.
…al LDS/RDS resources (grpc#7469)
No description provided.