-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
agent: avoid reverting any check updates that occur while a service is being added or the config is reloaded #6144
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s being added or the config is reloaded
banks
approved these changes
Jul 17, 2019
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.
Yay! Great job tracking this down.
pierresouchay
added a commit
to pierresouchay/consul
that referenced
this pull request
Feb 25, 2020
…ervices This fixes issue hashicorp#7318 Between versions 1.5.2 and 1.5.3, a regression has been introduced regarding health of services. A patch hashicorp#6144 had been issued for HealthChecks of nodes, but not for healthchecks of services. What happened when a reload was: 1. save all healthcheck statuses 2. cleanup everything 3. add new services with healthchecks In step 3, the state of healthchecks was taken into account locally, so at step 3, but since we cleaned up at step 2, state was lost. This PR introduces the snap parameter, so step 3 can use information from step 1
hanshasselberg
pushed a commit
that referenced
this pull request
Mar 9, 2020
…7345) This fixes issue #7318 Between versions 1.5.2 and 1.5.3, a regression has been introduced regarding health of services. A patch #6144 had been issued for HealthChecks of nodes, but not for healthchecks of services. What happened when a reload was: 1. save all healthcheck statuses 2. cleanup everything 3. add new services with healthchecks In step 3, the state of healthchecks was taken into account locally, so at step 3, but since we cleaned up at step 2, state was lost. This PR introduces the snap parameter, so step 3 can use information from step 1
freddygv
pushed a commit
that referenced
this pull request
Mar 12, 2020
…7345) This fixes issue #7318 Between versions 1.5.2 and 1.5.3, a regression has been introduced regarding health of services. A patch #6144 had been issued for HealthChecks of nodes, but not for healthchecks of services. What happened when a reload was: 1. save all healthcheck statuses 2. cleanup everything 3. add new services with healthchecks In step 3, the state of healthchecks was taken into account locally, so at step 3, but since we cleaned up at step 2, state was lost. This PR introduces the snap parameter, so step 3 can use information from step 1
Service A register with status=critical,then re-register with status=passing.This commit makes the "re-register" status still being critical. @rboyer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An Agent has two confusingly named locks:
Agent.stateLock
Agent.State
embedded lockOperations like
Agent.addServiceInternal
will grab the outer lock and then briefly acquire the inner lock to clone the current state of all of the checks registered on the agent. This is so that when a service is re-registered any checks re-added can have their statuses carried over.Unfortunately there is a logical data race (rather than a
-race
race) whereby the individual check goroutines (like for an alias check) are independently sending updated statuses into theAgent.State
and only acquiring the inner lock to do so.Example situation:
"foo"
.addServiceInternal
locks the outer locksnapshotCheckState
locks the inner lock, copies the check states, and unlocks the inner lock"bar"
has changed and callsState.UpdateCheck
to change fromcritical -> passing
."bar"
is flipped topassing
, and the inner lock is unlocked."foo"
service finishes being added and thedefer restoreCheckState
call walks the captured check snapshot from (3)."bar"
check is reverted back tocritical
as it was in step (3).The fix here is to only use the snapshot to seed the value of the check initially inserted/updated, rather than letting the check be inserted/updated at the default unmeasured state of
critical
.