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

[discovery] Emit only one log record per matched endpoint #4586

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

dmitryax
Copy link
Contributor

@dmitryax dmitryax commented Apr 2, 2024

This is another step towards migrating from the discovery events to entity events. Entity batch has to have only one entity with a unique identifier.

There is no reason to send a log record for every match. The matching rules should not conflict with each other. We can document and assume that.

The receiving part (discovery config provider) don't need all the matching states. It only maintains the latest state. And the successful state always wins. With this change, in case if we had conflicting matching rules across failed, partial and success sections, the result would be non-deterministic. However, given that we don't have any conflicting matching rules in the default discovery receiver configuration, it's safe to proceed.

As the next step, we will need to restructure the discovery rules schema to avoid any possible conflicts across different statuses.

@dmitryax dmitryax requested review from a team as code owners April 2, 2024 19:39
This is another step towards migrating from the discovery events to entity events. Entity batch has to have only one entity with a unique identifier.

There is no reason to send a log record for every match. The matching rules should not conflict with each other. We can document and assume that.

The receiving part (discovery config provider) don't need all the matching states. It only cares abut the latest state. And the successful state always wins. With this change, in case if we had a conflicting matching rules in both failed, partial and success sections, There is no reason to send log record per every would be unclear. However, given that we don't have any conflicting matching rules in the default discovery receiver configuration, it's safe to proceed.

As the next step, we will need to restructure the discovery rules schema to avoid any possible conflicts across different statuses.
@dmitryax dmitryax force-pushed the emit-only-one-discovery-log-per-endpoint branch from b46932a to 913c5d9 Compare April 2, 2024 20:29
if rStatusAttr, ok := lr.Attributes().Get(discovery.StatusAttr); ok {
rStatus := discovery.StatusType(rStatusAttr.Str())
if valid, e := discovery.IsValidStatus(rStatus); !valid {
d.logger.Debug("invalid status from log record", zap.Error(e), zap.Any("lr", lr.Body().AsRaw()))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is much more readable 👍🏽

@dmitryax dmitryax merged commit 50f2f7d into main Apr 2, 2024
28 checks passed
@dmitryax dmitryax deleted the emit-only-one-discovery-log-per-endpoint branch April 2, 2024 21:03
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2024
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