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

consul: handle nil multierror pointer correctly #24513

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Conversation

tgross
Copy link
Member

@tgross tgross commented Nov 20, 2024

When the service client syncs to Consul, we accumulate service sync errors in a multierror before reading all the local checks. If the API call to the local checks fails, we either return that error or append it to the multierror and return the set of errors. But multierror.Error.Len() doesn't nil-check, so we need to do this ourselves.

I've also made a quick pass through the rest of the code base looking for multierror Len method calls to see if we have this pattern elsewhere.

Fixes: #24512

Copy link
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for a quick fix!

@pkazmierczak
Copy link
Contributor

I'll let you be the judge if this warrants a changelog entry or not. Also: backport labels?

When the service client syncs to Consul, we accumulate service sync errors in a
multierror before reading all the local checks. If the API call to the local
checks fails, we either return that error or append it to the multierror and
return the set of errors. But `multierror.Error.Len()` doesn't nil-check, so we
need to do this ourselves.

I've also made a quick pass through the rest of the code base looking for
multierror `Len` method calls to see if we have this pattern elsewhere.

Fixes: #24512
@tgross tgross added backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.9.x backport to 1.9.x release line labels Nov 20, 2024
@tgross tgross merged commit 6b9dbef into main Nov 20, 2024
35 checks passed
@tgross tgross deleted the consul-multierr-panic branch November 20, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.9.x backport to 1.9.x release line theme/consul theme/crash type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

agent crash on Consul check sync failures
2 participants