Skip to content

Commit

Permalink
MTV-1775 | Fix not finished task NPE
Browse files Browse the repository at this point in the history
Issue:
If the snapshot creation task did not finish the controller fails with
NPE. This happens due to the taks not returning the result and we are
trying to typcase that result (nil) to the ManagedObject.

Fix:
Add check if the task finished or retry.

Signed-off-by: Martin Necas <[email protected]>
  • Loading branch information
mnecas committed Dec 17, 2024
1 parent 37b791e commit 5bb3c1c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/controller/plan/adapter/vsphere/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,20 @@ func (r *Client) CheckSnapshotReady(vmRef ref.Ref, precopy planapi.Precopy, host
r.Log.Info("Check Snapshot Ready", "vmRef", vmRef, "precopy", precopy)
taskInfo, err := r.getTaskById(vmRef, precopy.CreateTaskId, hosts)
if err != nil {
return false, snapshotId, liberr.Wrap(err)
return false, "", liberr.Wrap(err)
}
ready, err = r.checkTaskStatus(taskInfo)
if err != nil {
return false, "", liberr.Wrap(err)
}
if !ready {
// Task is not finished retry
return false, "", nil
}
if taskInfo.Result == nil {
// Empty result so the task did not finish retry
return false, "", nil
}
snapshotId = taskInfo.Result.(types.ManagedObjectReference).Value
return
}
Expand Down

0 comments on commit 5bb3c1c

Please sign in to comment.