mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
consul: Do not deregister external checks
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.
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user