From 3a8b82ae5a0defb1b8c199f732af8dc431131ec0 Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Fri, 13 Jul 2018 10:12:00 -0700 Subject: [PATCH 1/2] Don't shutdown if we lose leadership during lease restoration --- vault/expiration.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vault/expiration.go b/vault/expiration.go index a56e7fcb2e68..04e0f3dc08e7 100644 --- a/vault/expiration.go +++ b/vault/expiration.go @@ -307,6 +307,10 @@ func (m *ExpirationManager) Restore(errorFunc func()) (retErr error) { switch { case retErr == nil: + case errwrap.Contains(retErr, context.Canceled.Error()): + // Don't run error func because we're likely already shutting down + m.logger.Warn("context cancled while restoring leases, stopping lease loading") + retErr = nil case errwrap.Contains(retErr, ErrBarrierSealed.Error()): // Don't run error func because we're likely already shutting down m.logger.Warn("barrier sealed while restoring leases, stopping lease loading") From a42e2872b1ed32b890d1dab286c53b3473498cf7 Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Fri, 13 Jul 2018 10:13:50 -0700 Subject: [PATCH 2/2] Update comment --- vault/expiration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vault/expiration.go b/vault/expiration.go index 04e0f3dc08e7..0db360ca511f 100644 --- a/vault/expiration.go +++ b/vault/expiration.go @@ -308,7 +308,7 @@ func (m *ExpirationManager) Restore(errorFunc func()) (retErr error) { switch { case retErr == nil: case errwrap.Contains(retErr, context.Canceled.Error()): - // Don't run error func because we're likely already shutting down + // Don't run error func because we lost leadership m.logger.Warn("context cancled while restoring leases, stopping lease loading") retErr = nil case errwrap.Contains(retErr, ErrBarrierSealed.Error()):