From 43d88fecf71fedc484e1a21c9d0cfe849c0dbd6b Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Thu, 26 Oct 2023 14:55:52 +1100 Subject: [PATCH] provisioning task could be launched multiple times --- pkg/reconciler/taskrun/dynamic.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/reconciler/taskrun/dynamic.go b/pkg/reconciler/taskrun/dynamic.go index 242beb48..7f67d216 100644 --- a/pkg/reconciler/taskrun/dynamic.go +++ b/pkg/reconciler/taskrun/dynamic.go @@ -56,8 +56,11 @@ func (a DynamicResolver) Allocate(r *ReconcileTaskRun, ctx context.Context, log if address != "" { tr.Labels[AssignedHost] = tr.Annotations[CloudInstanceId] tr.Annotations[CloudAddress] = address - - err := launchProvisioningTask(r, ctx, log, tr, secretName, a.SshSecret, address, a.CloudProvider.SshUser()) + err := r.client.Update(ctx, tr) + if err != nil { + return reconcile.Result{}, err + } + err = launchProvisioningTask(r, ctx, log, tr, secretName, a.SshSecret, address, a.CloudProvider.SshUser()) if err != nil { //ugh, try and unassign err := a.CloudProvider.TerminateInstance(r.client, log, ctx, cloud.InstanceIdentifier(tr.Annotations[CloudInstanceId])) @@ -79,7 +82,7 @@ func (a DynamicResolver) Allocate(r *ReconcileTaskRun, ctx context.Context, log } } - return reconcile.Result{}, r.client.Update(ctx, tr) + return reconcile.Result{}, nil } else { //we are waiting for the instance to come up //so just requeue