From 6845cf825a8b7364d1fa3139da34b7d18ceeea79 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Mon, 17 Aug 2020 11:30:21 -0700 Subject: [PATCH] Delete and recreate lease on conflict This takes a somewhat hamfisted approach at dealing with lease conflicts. This can happen if "someone" changes the lease underneath us. Again, this should happen rarely, but it can happen (And does happen in production systems). Signed-off-by: Sargun Dhillon --- node/node.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node/node.go b/node/node.go index c7ab7448b..284f72815 100644 --- a/node/node.go +++ b/node/node.go @@ -424,7 +424,8 @@ func ensureLease(ctx context.Context, leases v1beta1.LeaseInterface, lease *coor case errors.IsNotFound(err): log.G(ctx).WithError(err).Info("Node lease not supported") return nil, err - case errors.IsAlreadyExists(err): + case errors.IsAlreadyExists(err), errors.IsConflict(err): + log.G(ctx).WithError(err).Warn("Error creating lease, deleting and recreating") if err := leases.Delete(ctx, lease.Name, metav1.DeleteOptions{}); err != nil && !errors.IsNotFound(err) { log.G(ctx).WithError(err).Error("could not delete old node lease") return nil, pkgerrors.Wrap(err, "old lease exists but could not delete it")