Skip to content

Commit

Permalink
Check that the old VM has been deleted before creating a new VM (open…
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Kirii authored and pierreprinetti committed Apr 22, 2024
1 parent 932136a commit 5f4d563
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/cloud/openstack/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
UserDataKey = "userData"

TimeoutInstanceCreate = 5 * time.Minute
TimeoutInstanceDelete = 5 * time.Minute
RetryIntervalInstanceStatus = 10 * time.Second

TokenTTL = 60 * time.Minute
Expand Down Expand Up @@ -229,6 +230,18 @@ func (oc *OpenstackClient) Update(ctx context.Context, cluster *clusterv1.Cluste
if err != nil {
klog.Errorf("delete machine %s for update failed: %v", currentMachine.ObjectMeta.Name, err)
} else {
err = util.PollImmediate(RetryIntervalInstanceStatus, TimeoutInstanceDelete, func() (bool, error) {
instance, err := oc.instanceExists(machine)
if err != nil {
return false, nil
}
return instance == nil, nil
})
if err != nil {
return oc.handleMachineError(machine, apierrors.DeleteMachine(
"error deleting Openstack instance: %v", err))
}

err = oc.Create(ctx, cluster, machine)
if err != nil {
klog.Errorf("create machine %s for update failed: %v", machine.ObjectMeta.Name, err)
Expand Down

0 comments on commit 5f4d563

Please sign in to comment.