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

LEDS: base implementation #17869

Merged
merged 5 commits into from
Aug 31, 2021
Merged

LEDS: base implementation #17869

merged 5 commits into from
Aug 31, 2021

Conversation

adisuissa
Copy link
Contributor

Commit Message: LEDS - base implementation
Additional Description:
The implementation of the main logic behind the LEDS protocol.
This is not integrated into ClusterLoadAssignment processing (not plumbed in yet).
Risk Level: Low.
Testing: Unit test (integration tests will be added in future PR, when it is integrated).
Docs Changes:
Release Notes:
Platform Specific Features:
Part of #10373

Signed-off-by: Adi Suissa-Peleg [email protected]

Signed-off-by: Adi Suissa-Peleg <[email protected]>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice to see this moving forward. Flushing some comments from a first pass.

/wait

// unsuccessful).
const UpdateCb callback_;
// Once the endpoints of the locality are updated, it is considered active.
bool active_{false};
Copy link
Member

Choose a reason for hiding this comment

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

"active" confused me on first read. I might recommend initial_update_attempt_complete_ or something like that with matching accessor above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

callback_();
}

bool LedsSubscription::validateUpdateSize(int num_resources) { return num_resources > 0; }
Copy link
Member

Choose a reason for hiding this comment

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

nit: I don't think this function adds much. I would just inline it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

continue;
}

auto resource_it = endpoint_entry_map_.find(added_resource_name);
Copy link
Member

Choose a reason for hiding this comment

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

perf nit: I think you can potentially avoid a double lookup on add by just using [] lookup and getting a reference and see if there is a valid iterator or not (you might need some wrapper which initializes the iterator to end()). Not sure if this is worth it or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As suggested in another comment, I've modified it from a list and map to a map only, so I think this comment is outdated.

Comment on lines 85 to 87
envoy::config::endpoint::v3::LbEndpoint lb_endpoint =
dynamic_cast<const envoy::config::endpoint::v3::LbEndpoint&>(
added_resource.get().resource());
Copy link
Member

Choose a reason for hiding this comment

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

nit: you can lift this to above and then use in both places.

I suppose in both cases you need to copy but not sure if there would be any perf benefit to trying to move the proto or not.

Copy link
Contributor 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 49 to 50
// Fetch all the endpoints in the locality subscription.
const LbEndpointList& getEndpoints() const { return endpoints_; }
Copy link
Member

Choose a reason for hiding this comment

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

Thinking to future changes, do you need this list at all? Could you just return the map and have the consumer iterate over that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
The idea to only return the list was to abstract over the resource names, as they are not really needed by the consumer, but it may be relevant for future changes, so modified to returning the map instead.

Comment on lines 56 to 60
if (!Config::XdsResourceIdentifier::hasXdsTpScheme(removed_resource_name)) {
ENVOY_LOG(warn,
"Received non-glob collection resource name for an unsubscribed resource {} in "
"LEDS update for cluster: {}. Skipping entry.",
removed_resource_name, cluster_name_);
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this error checking and the error message here and below.

Don't you want to actually check to see if the resource name is in the glob prefix that you subscribed to? This is just checking that it starts with xdstp://, which while seems valid, I don't think matches the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.
The motivation was to verify that only resources matching the glob collection are part of the added/removed resources lists. I've taken another look, and this is already being done in the watch-map code, so no need for this verification here.

@mattklein123
Copy link
Member

Thanks LGTM but I think needs a tidy fix.

/wait

Signed-off-by: Adi Suissa-Peleg <[email protected]>
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