From 313b1fa9c6b205d06d979e73543cd47d477cf00d Mon Sep 17 00:00:00 2001 From: alejandroEsc Date: Wed, 1 Sep 2021 10:13:32 -0400 Subject: [PATCH] fix: make move idempotent by handling machine objs correctly ran gofmt remove generateName metadata instead of changing the AlreadyExist error remove unnecessary comment Update cmd/clusterctl/client/cluster/mover.go Co-authored-by: Daniel Lipovetsky <3445370+dlipovetsky@users.noreply.github.com> Update cmd/clusterctl/client/cluster/mover.go Co-authored-by: Vince Prignano --- cmd/clusterctl/client/cluster/mover.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/clusterctl/client/cluster/mover.go b/cmd/clusterctl/client/cluster/mover.go index a64426724a69..07330b0f6b76 100644 --- a/cmd/clusterctl/client/cluster/mover.go +++ b/cmd/clusterctl/client/cluster/mover.go @@ -735,6 +735,12 @@ func (o *objectMover) createTargetObject(nodeToCreate *node, toProxy Proxy) erro // Rebuild the owne reference chain o.buildOwnerChain(obj, nodeToCreate) + // FIXME Workaround for https://github.com/kubernetes/kubernetes/issues/32220. Remove when the issue is fixed. + // If the resource already exists, the API server ordinarily returns an AlreadyExists error. Due to the above issue, if the resource has a non-empty metadata.generateName field, the API server returns a ServerTimeoutError. To ensure that the API server returns an AlreadyExists error, we set the metadata.generateName field to an empty string. + if len(obj.GetName()) > 0 && len(obj.GetGenerateName()) > 0 { + obj.SetGenerateName("") + } + // Creates the targetObj into the target management cluster. cTo, err := toProxy.NewClient() if err != nil {