Skip to content

Commit

Permalink
update maintenance check to passing before removing
Browse files Browse the repository at this point in the history
Without this update service using `consul watch` to monitor check
changes will never see maintenance mode being disabled.

Resolves: hashicorp#11330

Signed-off-by: Jakub Sokołowski <[email protected]>
  • Loading branch information
jakubgs authored and siddarthkay committed May 2, 2024
1 parent bbd8080 commit 61317d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/11332.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
agent: update maintenance check to passing before removing
```
8 changes: 8 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4234,6 +4234,10 @@ func (a *Agent) DisableServiceMaintenance(serviceID structs.ServiceID) error {
return nil
}

// Update check to trigger an event for watchers
a.State.UpdateCheck(checkID, api.HealthPassing, "")
// Make sure state change is propagated
a.State.SyncChanges()
// Deregister the maintenance check
a.RemoveCheck(checkID, true)
a.logger.Info("Service left maintenance mode", "service", serviceID.String())
Expand Down Expand Up @@ -4271,6 +4275,10 @@ func (a *Agent) DisableNodeMaintenance() {
if a.State.Check(structs.NodeMaintCheckID) == nil {
return
}
// Update check to trigger an event for watchers
a.State.UpdateCheck(structs.NodeMaintCheckID, api.HealthPassing, "")
// Make sure state change is propagated
a.State.SyncChanges()
a.RemoveCheck(structs.NodeMaintCheckID, true)
a.logger.Info("Node left maintenance mode")
}
Expand Down

0 comments on commit 61317d8

Please sign in to comment.