|
|
@ -4194,7 +4194,7 @@ func (a *Agent) EnableServiceMaintenance(serviceID structs.ServiceID, reason, to
|
|
|
|
|
|
|
|
|
|
|
|
// Check if maintenance mode is not already enabled
|
|
|
|
// Check if maintenance mode is not already enabled
|
|
|
|
checkID := serviceMaintCheckID(serviceID)
|
|
|
|
checkID := serviceMaintCheckID(serviceID)
|
|
|
|
if a.State.Check(checkID) != nil && a.State.Check(checkID).Status != api.HealthPassing {
|
|
|
|
if a.State.Check(checkID) != nil {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -4203,7 +4203,7 @@ func (a *Agent) EnableServiceMaintenance(serviceID structs.ServiceID, reason, to
|
|
|
|
reason = defaultServiceMaintReason
|
|
|
|
reason = defaultServiceMaintReason
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// New Critical Health Check
|
|
|
|
// Create and register the critical health check
|
|
|
|
check := &structs.HealthCheck{
|
|
|
|
check := &structs.HealthCheck{
|
|
|
|
Node: a.config.NodeName,
|
|
|
|
Node: a.config.NodeName,
|
|
|
|
CheckID: checkID.ID,
|
|
|
|
CheckID: checkID.ID,
|
|
|
@ -4215,17 +4215,7 @@ func (a *Agent) EnableServiceMaintenance(serviceID structs.ServiceID, reason, to
|
|
|
|
Type: "maintenance",
|
|
|
|
Type: "maintenance",
|
|
|
|
EnterpriseMeta: checkID.EnterpriseMeta,
|
|
|
|
EnterpriseMeta: checkID.EnterpriseMeta,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a.AddCheck(check, nil, true, token, ConfigSourceLocal)
|
|
|
|
// If check exists, update status, else create a new check
|
|
|
|
|
|
|
|
if a.State.Check(checkID) != nil {
|
|
|
|
|
|
|
|
a.State.UpdateCheck(checkID, api.HealthCritical, "")
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
err := a.AddCheck(check, nil, true, token, ConfigSourceLocal)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a.logger.Info("Service entered maintenance mode", "service", serviceID.String())
|
|
|
|
a.logger.Info("Service entered maintenance mode", "service", serviceID.String())
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -4248,11 +4238,9 @@ func (a *Agent) DisableServiceMaintenance(serviceID structs.ServiceID) error {
|
|
|
|
// Update check to trigger an event for watchers
|
|
|
|
// Update check to trigger an event for watchers
|
|
|
|
a.State.UpdateCheck(checkID, api.HealthPassing, "")
|
|
|
|
a.State.UpdateCheck(checkID, api.HealthPassing, "")
|
|
|
|
// Make sure state change is propagated
|
|
|
|
// Make sure state change is propagated
|
|
|
|
err := a.State.SyncFull()
|
|
|
|
a.State.SyncChanges()
|
|
|
|
if err != nil {
|
|
|
|
// Deregister the maintenance check
|
|
|
|
return err
|
|
|
|
a.RemoveCheck(checkID, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a.logger.Info("Service left maintenance mode", "service", serviceID.String())
|
|
|
|
a.logger.Info("Service left maintenance mode", "service", serviceID.String())
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|