From 9e4f8a4786c3bdb674f9b4fe841871277dee85e4 Mon Sep 17 00:00:00 2001 From: Yassine TIJANI Date: Wed, 1 Jul 2020 10:44:33 +0200 Subject: [PATCH] re-apply the conccurent clones fix Signed-off-by: Yassine TIJANI --- controllers/vspherevm_controller.go | 7 ------- pkg/services/govmomi/vcenter/clone.go | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/controllers/vspherevm_controller.go b/controllers/vspherevm_controller.go index e3c23063b4..a3f203f4b8 100644 --- a/controllers/vspherevm_controller.go +++ b/controllers/vspherevm_controller.go @@ -332,13 +332,6 @@ func (r vmReconciler) reconcileNormal(ctx *context.VMContext) (reconcile.Result, return reconcile.Result{}, errors.Errorf("bios uuid is empty while VM is ready") } - // patch the vsphereVM early to ensure that the task is - // reflected in the status right away, this avoid situations - // of concurrent clones - if err := ctx.Patch(); err != nil { - ctx.Logger.Error(err, "patch failed", "vspherevm", ctx.VSphereVM) - } - // Update the VSphereVM's network status. r.reconcileNetwork(ctx, vm) diff --git a/pkg/services/govmomi/vcenter/clone.go b/pkg/services/govmomi/vcenter/clone.go index b8709ef73c..30834ec9ed 100644 --- a/pkg/services/govmomi/vcenter/clone.go +++ b/pkg/services/govmomi/vcenter/clone.go @@ -182,6 +182,12 @@ func Clone(ctx *context.VMContext, bootstrapData []byte) error { ctx.VSphereVM.Status.TaskRef = task.Reference().Value + // patch the vsphereVM early to ensure that the task is + // reflected in the status right away, this avoid situations + // of concurrent clones + if err := ctx.Patch(); err != nil { + ctx.Logger.Error(err, "patch failed", "vspherevm", ctx.VSphereVM) + } return nil }