Skip to content

Commit

Permalink
consul: Do not deregister external checks
Browse files Browse the repository at this point in the history
This commit causes sync to skip deregistering checks that are not
managed by nomad, such as service maintenance mode checks.  This is
handled in the same way as service registrations - by doing a Nomad
specific prefix match.
  • Loading branch information
endocrimes committed May 2, 2019
1 parent 195529e commit 14c231a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion command/agent/consul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func (c *ServiceClient) sync() error {
// Nomad managed checks if this is not a client agent.
// This is to prevent server agents from removing checks
// registered by client agents
if !isNomadService(check.ServiceID) || !c.isClientAgent {
if !isNomadService(check.ServiceID) || !c.isClientAgent || !isNomadCheck(check.CheckID) {
// Service not managed by Nomad, skip
continue
}
Expand Down Expand Up @@ -1182,6 +1182,12 @@ func createCheckReg(serviceID, checkID string, check *structs.ServiceCheck, host
return &chkReg, nil
}

// isNomadCheck returns true if the ID matches the pattern of a Nomad managed
// check.
func isNomadCheck(id string) bool {
return strings.HasPrefix(id, nomadCheckPrefix)
}

// isNomadService returns true if the ID matches the pattern of a Nomad managed
// service (new or old formats). Agent services return false as independent
// client and server agents may be running on the same machine. #2827
Expand Down

0 comments on commit 14c231a

Please sign in to comment.