From 99635cd56d9292a76952c22a313c355f66e443da Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 17 Apr 2020 15:39:02 +0200 Subject: [PATCH] feat: max retries of 5 for client logout --- pkg/pmapi/clientmanager.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/pmapi/clientmanager.go b/pkg/pmapi/clientmanager.go index a681e2a1..c1b24e7a 100644 --- a/pkg/pmapi/clientmanager.go +++ b/pkg/pmapi/clientmanager.go @@ -11,6 +11,8 @@ import ( "github.com/sirupsen/logrus" ) +const maxLogoutRetries = 5 + // ClientManager is a manager of clients. type ClientManager struct { // newClient is used to create new Clients. By default this creates pmapi clients but it can be overridden to @@ -153,8 +155,17 @@ func (cm *ClientManager) LogoutClient(userID string) { return } + var retries int + for client.DeleteAuth() == ErrAPINotReachable { - cm.log.Warn("Logging out client failed because API was not reachable, retrying...") + retries++ + + if retries > maxLogoutRetries { + cm.log.Error("Failed to delete client auth (retried too many times)") + break + } + + cm.log.Warn("Failed to delete client auth because API was not reachable, retrying...") } }() }