From 6d1cb88b73e2d2841ced658c79dd0e892b936505 Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Tue, 6 Nov 2018 23:11:40 -0500 Subject: [PATCH] Do not retry conflicts during storage migration Storage migration is special in that all it needs to do is a no-op update to cause the API server to migrate the object to the preferred version. Thus if we encounter a conflict, we know that something updated the object and we no longer need to do anything. If the object needed migration, the API server has already migrated it. Signed-off-by: Monis Khan --- pkg/oc/cli/admin/migrate/storage/storage.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/oc/cli/admin/migrate/storage/storage.go b/pkg/oc/cli/admin/migrate/storage/storage.go index 50c8d5453997..dd07850712a9 100644 --- a/pkg/oc/cli/admin/migrate/storage/storage.go +++ b/pkg/oc/cli/admin/migrate/storage/storage.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" "golang.org/x/time/rate" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/sets" @@ -302,6 +303,13 @@ func (o *MigrateAPIStorageOptions) save(info *resource.Info, reporter migrate.Re Resource(info.Mapping.Resource). Namespace(info.Namespace). Update(oldObject) + // storage migration is special in that all it needs to do is a no-op update to cause + // the api server to migrate the object to the preferred version. thus if we encounter + // a conflict, we know that something updated the object and we no longer need to do + // anything - if the object needed migration, the api server has already migrated it. + if errors.IsConflict(err) { + return migrate.ErrUnchanged + } if err != nil { return migrate.DefaultRetriable(info, err) }