From 9a548a8659efc6e63bd4492679f4dff9e69d092a Mon Sep 17 00:00:00 2001 From: Eric Suen Date: Tue, 22 Oct 2019 16:51:27 -0700 Subject: [PATCH] Automatically delete a dangling RU when a there's a deploy attempt with only one RC. --- pkg/store/consul/rollstore/consul_store.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/store/consul/rollstore/consul_store.go b/pkg/store/consul/rollstore/consul_store.go index 81653fdfe..84ff3350c 100644 --- a/pkg/store/consul/rollstore/consul_store.go +++ b/pkg/store/consul/rollstore/consul_store.go @@ -341,7 +341,17 @@ func (s ConsulStore) CreateRollingUpdateFromOneExistingRCWithID( err = s.checkForConflictingUpdates(rcIDs) if err != nil { - return roll_fields.Update{}, err + conflictingErr, ok := err.(ConflictingRUError) + if !ok { + return roll_fields.Update{}, err + } + // There is an unknown reason where sometimes an RU still exists when it + // shouldn't. This deletes the dangling RU which is what we've been + // doing manually + err = s.Delete(ctx, conflictingErr.ConflictingID) + if err != nil { + return roll_fields.Update{}, err + } } rc, err := s.rcstore.CreateTxn(ctx, newRCManifest, newRCNodeSelector, availabilityZone, clusterName, newRCPodLabels, newRCLabels, newAllocationStrategy)