Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions internal/controller/controllers/agent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import (

const (
AgentFinalizerName = "agent." + aiv1beta1.Group + "/ai-deprovision"
AgentSpokeCleanupAnnotation = "agent." + aiv1beta1.Group + "/clean-spoke-on-delete"
BaseLabelPrefix = aiv1beta1.Group + "/"
InventoryLabelPrefix = "inventory." + BaseLabelPrefix
AgentLabelHasNonrotationalDisk = InventoryLabelPrefix + "storage-hasnonrotationaldisk"
Expand Down Expand Up @@ -398,16 +399,7 @@ func (r *AgentReconciler) handleAgentFinalizer(ctx context.Context, log logrus.F
}
} else { // agent is being deleted
if funk.ContainsString(agent.GetFinalizers(), AgentFinalizerName) {
if _, has_annotation := agent.GetAnnotations()[BMH_FINALIZER_NAME]; has_annotation && agent.Spec.ClusterDeploymentName != nil {
// wait for BMH to be deleted
if foundBMH, err := r.bmhExists(ctx, agent); err != nil || foundBMH {
if err != nil {
log.WithError(err).Warnf("failed to determine if BMH exists for agent")
}
log.Info("waiting for BMH to be deleted")
return &ctrl.Result{RequeueAfter: defaultRequeueAfterOnError}, err
}

if _, has_annotation := agent.GetAnnotations()[AgentSpokeCleanupAnnotation]; has_annotation && agent.Spec.ClusterDeploymentName != nil {
// only remove the spoke resources if the entire cluster isn't being deleted
clusterExists, err := r.clusterExists(ctx, agent)
if err != nil {
Expand Down
Loading