From c4534bc53dffced68472df5f256a053f8f96e5c1 Mon Sep 17 00:00:00 2001 From: Jared Kirschner Date: Thu, 7 Apr 2022 13:10:20 -0700 Subject: [PATCH] improve error msg for deregister critical service If a service is automatically registered because it has a critical health check for longer than deregister_critical_service_after, the error message will now include: - mention of the deregister_critical_service_after option - the value of deregister_critical_service_after for that check --- .changelog/12725.txt | 3 +++ agent/agent.go | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changelog/12725.txt diff --git a/.changelog/12725.txt b/.changelog/12725.txt new file mode 100644 index 0000000000..3cba2d2504 --- /dev/null +++ b/.changelog/12725.txt @@ -0,0 +1,3 @@ +```release-note:improvement +agent: improve log messages when a service with a critical health check is deregistered due to exceeding the deregister_critical_service_after timeout +``` \ No newline at end of file diff --git a/agent/agent.go b/agent/agent.go index c08316fd8e..818587407d 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1813,14 +1813,17 @@ func (a *Agent) reapServicesInternal() { if timeout > 0 && cs.CriticalFor() > timeout { reaped[serviceID] = true if err := a.RemoveService(serviceID); err != nil { - a.logger.Error("unable to deregister service after check has been critical for too long", + a.logger.Error("failed to deregister service with critical health that exceeded health check's 'deregister_critical_service_after' timeout", "service", serviceID.String(), "check", checkID.String(), - "error", err) + "timeout", timeout.String(), + "error", err, + ) } else { - a.logger.Info("Check for service has been critical for too long; deregistered service", + a.logger.Info("deregistered service with critical health due to exceeding health check's 'deregister_critical_service_after' timeout", "service", serviceID.String(), "check", checkID.String(), + "timeout", timeout.String(), ) } }