Skip to content

Commit

Permalink
Revert "Replace deprecated wait functions"
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Apr 2, 2024
1 parent 5205edb commit 3ff8bf7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hack/tools/janitor/janitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (s *janitor) deleteVSphereVMs(ctx context.Context, folder string) error {

func waitForTasksFinished(ctx context.Context, tasks []*object.Task, ignoreErrors bool) error {
for _, t := range tasks {
if err := t.WaitEx(ctx); !ignoreErrors && err != nil {
if err := t.Wait(ctx); !ignoreErrors && err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/govmomi/cluster/vmgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Test_VMGroup(t *testing.T) {

task, err := vmGrp.Add(ctx, vmRef)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(task.WaitEx(ctx)).To(Succeed())
g.Expect(task.Wait(ctx)).To(Succeed())
g.Expect(vmGrp.listVMs()).To(HaveLen(3))

hasVM, err = vmGrp.HasVM(vmRef)
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/govmomi/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestCreate(t *testing.T) {
t.Fatal("could not make vim25 client.")
}
task := object.NewTask(vimClient, taskRef)
err = task.WaitEx(ctx)
err = task.Wait(ctx)
if err != nil {
t.Fatal("error waiting for task:", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/services/govmomi/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func reconcileVSphereVMWhenNetworkIsReady(ctx context.Context, virtualMachineCtx
&virtualMachineCtx.VMContext,
func() (<-chan []interface{}, <-chan error, error) {
// Wait for the VM to be powered on.
powerOnTaskInfo, err := powerOnTask.WaitForResultEx(ctx)
powerOnTaskInfo, err := powerOnTask.WaitForResult(ctx)

Check warning on line 195 in pkg/services/govmomi/util.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/govmomi/util.go#L195

Added line #L195 was not covered by tests
if err != nil && powerOnTaskInfo == nil {
return nil, nil, errors.Wrapf(err, "failed to wait for power on op for vm %s", ctx)
}
Expand Down Expand Up @@ -255,7 +255,7 @@ func reconcileVSphereVMOnTaskCompletion(ctx context.Context, vmCtx *capvcontext.
"taskDescriptionID", task.Info.DescriptionId)

reconcileVSphereVMOnFuncCompletion(ctx, vmCtx, func() ([]interface{}, error) {
taskInfo, err := taskHelper.WaitForResultEx(ctx)
taskInfo, err := taskHelper.WaitForResult(ctx)

Check warning on line 258 in pkg/services/govmomi/util.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/govmomi/util.go#L258

Added line #L258 was not covered by tests

// An error is only returned if the process of waiting for the result
// failed, *not* if the task itself failed.
Expand Down
6 changes: 3 additions & 3 deletions test/infrastructure/vcsim/controllers/vmip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r *vmIPReconciler) ReconcileIP(ctx context.Context) (ctrl.Result, error) {
if err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to PowerOff vm")
}
if err = task.WaitEx(ctx); err != nil {
if err = task.Wait(ctx); err != nil { // deprecation on Wait is going to be removed, see https://github.com/vmware/govmomi/issues/3394
return reconcile.Result{}, errors.Wrapf(err, "failed to PowerOff vm task to complete")
}

Expand Down Expand Up @@ -117,7 +117,7 @@ func (r *vmIPReconciler) ReconcileIP(ctx context.Context) (ctrl.Result, error) {
if err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to Customize vm")
}
if err = task.WaitEx(ctx); err != nil {
if err = task.Wait(ctx); err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to wait for Customize vm task to complete")
}

Expand All @@ -126,7 +126,7 @@ func (r *vmIPReconciler) ReconcileIP(ctx context.Context) (ctrl.Result, error) {
if err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to PowerOn vm")
}
if err = task.WaitEx(ctx); err != nil {
if err = task.Wait(ctx); err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to PowerOn vm task to complete")
}

Expand Down

0 comments on commit 3ff8bf7

Please sign in to comment.