Skip to content

Commit

Permalink
fix: make move idempotent by handling machine objs correctly
Browse files Browse the repository at this point in the history
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 <[email protected]>

Update cmd/clusterctl/client/cluster/mover.go

Co-authored-by: Vince Prignano <[email protected]>
  • Loading branch information
alejandroEsc and vincepri committed Sep 2, 2021
1 parent ec87b00 commit 313b1fa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/clusterctl/client/cluster/mover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 313b1fa

Please sign in to comment.