Skip to content

Commit

Permalink
fix: call deprovision only after the machine request status is deleted
Browse files Browse the repository at this point in the history
Otherwise the infra provider stops the machine before Omni can run the
reset and everything gets stuck when the machine is allocated into a
cluster.

Also fix labels not being reset on the machine status.

Signed-off-by: Artem Chernyshev <[email protected]>
(cherry picked from commit 3ef1f85)
  • Loading branch information
Unix4ever committed Sep 17, 2024
1 parent 42218d0 commit 89860d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/pkg/infra/controllers/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,15 @@ func (ctrl *ProvisionController[T]) reconcileTearingDown(ctx context.Context, r
return err
}

if err = ctrl.provisioner.Deprovision(ctx, logger, t, machineRequest); err != nil {
return err
}

resources := []resource.Metadata{
resource.NewMetadata(t.ResourceDefinition().DefaultNamespace, t.ResourceDefinition().Type, machineRequest.Metadata().ID(), resource.VersionUndefined),
*infra.NewMachineRequestStatus(machineRequest.Metadata().ID()).Metadata(),
}

for _, md := range resources {
ready, err := r.Teardown(ctx, md)
var ready bool

ready, err = r.Teardown(ctx, md)
if err != nil {
if state.IsNotFoundError(err) {
continue
Expand All @@ -310,6 +308,10 @@ func (ctrl *ProvisionController[T]) reconcileTearingDown(ctx context.Context, r
}
}

if err = ctrl.provisioner.Deprovision(ctx, logger, t, machineRequest); err != nil {
return err
}

logger.Info("machine deprovisioned", zap.String("request_id", machineRequest.Metadata().ID()))

return r.RemoveFinalizer(ctx, machineRequest.Metadata(), ctrl.Name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ func (ctrl *MachineStatusController) setClusterRelation(in inputs, machineStatus
machineStatus.Metadata().Labels().Set(omni.MachineStatusLabelAvailable, "")

machineStatus.Metadata().Labels().Delete(omni.LabelCluster)
machineStatus.Metadata().Labels().Delete(omni.LabelControlPlaneRole)
machineStatus.Metadata().Labels().Delete(omni.LabelWorkerRole)

return nil
}
Expand Down

0 comments on commit 89860d5

Please sign in to comment.