Skip to content

xds: suppress the duplicate errors at the client side#9185

Open
mswierq wants to merge 6 commits into
grpc:masterfrom
mswierq:fix/8994-suppress-duplicate-errors
Open

xds: suppress the duplicate errors at the client side#9185
mswierq wants to merge 6 commits into
grpc:masterfrom
mswierq:fix/8994-suppress-duplicate-errors

Conversation

@mswierq

@mswierq mswierq commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #8994

This change suppresses duplicate errors on the xds client side by skipping calling watchers for the duplicates. This also prevents generating new child names for the same broken EDS resource (EDS resource has no localities) that is being re-send by the control plane.

RELEASE NOTES:

  • xds: handle receipt of duplicated errors at the client side by suppressing them in the same manner the duplicate updates are suppressed

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.22%. Comparing base (1a80fca) to head (bc6a797).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9185      +/-   ##
==========================================
- Coverage   83.23%   83.22%   -0.02%     
==========================================
  Files         420      420              
  Lines       34024    34035      +11     
==========================================
+ Hits        28321    28325       +4     
+ Misses       4275     4274       -1     
- Partials     1428     1436       +8     
Files with missing lines Coverage Δ
internal/xds/clients/xdsclient/authority.go 79.90% <100.00%> (-0.90%) ⬇️

... and 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mbissa mbissa self-assigned this Jun 16, 2026
@easwars easwars requested a review from eshitachandwani June 17, 2026 18:20
@easwars easwars added Type: Bug Area: xDS Includes everything xDS related, including LB policies used with xDS. labels Jun 17, 2026
@easwars easwars added this to the 1.83 Release milestone Jun 17, 2026
isDuplicateErr := state.md.ErrState != nil && state.md.ErrState.Err != nil && state.md.ErrState.Err.Error() == uErr.Err.Error()
var errState *xdsresource.UpdateErrorMetadata
if md.ErrState != nil {
errState = &xdsresource.UpdateErrorMetadata{

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.

Why do we need to do this ? Can't we directly do state.md.ErrState = md.ErrState like earlier ?

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.

md.ErrState contains concatenated errors for all resources in the received update, so it's impossible to detect an error duplication right, if there was more than one error. It might be worth it to keep uErr.Err (which is a resource specific error) as a separate member in the state to avoid confusion? WDYT?

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 dont think that is the right way to go. We should not change the error stored. We can instead compare the error in state with the ms error like :
isDuplicateErr := state.md.ErrState != nil && state.md.ErrState.Err != nil && state.md.ErrState.Err.Error() == md.ErrState.Err.Error()
WDYT ?

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.

We cannot compare state.md.ErrState.Err.Error() == md.ErrState.Err.Error() in order to detect a duplication, e.g. Let's assume that we got an update for three resources, where two of them got errors:

  • Resource A (Ok)
  • Resource B (Error B)
  • Resource C (Error C)

md.ErrState.Err.Error() returns a concatenated error "Error B; Error C". This concatenated error is stored in state.md.ErrState.

Then the next update brings a duplicate error for the Resource C only, because Resource B is fine, we did not get an update for that resource or the error is different:

  • Resource A (Ok)
  • Resource B (Ok)
  • Resource C (Error C)

md.ErrState.Err.Error() returns a concatenated error "Error C", which is different from the previously stored one "Error B; Error C". Even though the duplication is there a simple comparison will not work.

As an alternative I can try to check if the concatenated error in the md.ErrState contains a resource specific error to seek for a duplication.

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.

I have changed the logic to look for a duplicate resource error in the concatenated error (md.ErrState)

})
}
state.md.ErrState = md.ErrState
isDuplicateErr := state.md.ErrState != nil && state.md.ErrState.Err != nil && state.md.ErrState.Err.Error() == uErr.Err.Error()

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.

Also instead of evaluating this as a variable and then checking can we instead do the assignment first(which I assume needs to be done for either case) and then directly in an if block we can evaluate the condition and call continue on true. WDYT ?

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.

state works as an cache of the previously received error for the resource, so trying to find out if there was an error duplication after updating state would always return true

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.

Right! but we can do the check first and if true call continue, because if we are getting the same error, we might not need to update the state? Or can the status be different ?

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.

The stored metadata ErrState may differ, this is why we need to update it even if a duplicate error for a resource is detected. This is also the reason why the duplicate check has to be done before updating it. Please, look at the comment with an example that I made: #9185 (comment)

Comment thread internal/xds/xdsclient/tests/eds_watchers_test.go
@eshitachandwani eshitachandwani modified the milestone: 1.83 Release Jun 22, 2026
@eshitachandwani

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces duplicate error suppression for ADS resource updates in the xDS client, skipping watcher notifications when duplicate errors are received, and adds a corresponding test to verify this behavior. The reviewer identified a critical issue in authority.go where a nil pointer dereference panic could occur if md.ErrState is nil but uErr.Err is non-nil, and provided a code suggestion to safely initialize errState.

Comment thread internal/xds/clients/xdsclient/authority.go Outdated
@easwars easwars assigned eshitachandwani and unassigned mswierq and mbissa Jul 8, 2026
@eshitachandwani eshitachandwani self-requested a review July 8, 2026 15:12
// duplicate error notification to the watcher.
//
// Note: This behavior (suppress duplicate error notifications to watchers) was
// originally introduced to handle invalid EDS resources (missing localities) as

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 don't think we need this note here.

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.

removed

}
if req.GetErrorDetail() != nil {
if count := nackCount.Add(1); count >= 3 {
nackReceivedCh.Send(nil)

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.

nit: Can we change the nackReceivedCh to be a go channel and close it here since it is only sent to once. We do not need a size one channel.

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.

fixed

isDuplicateErr := state.md.ErrState != nil && state.md.ErrState.Err != nil && state.md.ErrState.Err.Error() == uErr.Err.Error()
var errState *xdsresource.UpdateErrorMetadata
if md.ErrState != nil {
errState = &xdsresource.UpdateErrorMetadata{

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 dont think that is the right way to go. We should not change the error stored. We can instead compare the error in state with the ms error like :
isDuplicateErr := state.md.ErrState != nil && state.md.ErrState.Err != nil && state.md.ErrState.Err.Error() == md.ErrState.Err.Error()
WDYT ?

})
}
state.md.ErrState = md.ErrState
isDuplicateErr := state.md.ErrState != nil && state.md.ErrState.Err != nil && state.md.ErrState.Err.Error() == uErr.Err.Error()

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.

Right! but we can do the check first and if true call continue, because if we are getting the same error, we might not need to update the state? Or can the status be different ?

@easwars easwars removed this from the 1.83 Release milestone Jul 14, 2026
@easwars easwars added this to the 1.84 Release milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: xDS Includes everything xDS related, including LB policies used with xDS. Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cdsbalancer: priority LB name generation logic creates new names everytime when the EDS resource has no localities

4 participants