Skip to content
Closed
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
4 changes: 4 additions & 0 deletions pkg/apis/machine/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const (
// MachineClusterIDLabel is the label that a machine must have to identify the
// cluster to which it belongs.
MachineClusterIDLabel = "machine.openshift.io/cluster-api-cluster"

// PreserveInstanceAnnotation prevents a VM from being deleted by the
// machine-controller and will cause machine-controller to requeue.
PreserveInstanceAnnotation = "machine.openshift.io/preserve-instance"
)

// +genclient
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/machine/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ func (r *ReconcileMachine) getCluster(ctx context.Context, machine *machinev1.Ma
}

func (r *ReconcileMachine) isDeleteAllowed(machine *machinev1.Machine) bool {
_, exists := machine.ObjectMeta.Annotations[machinev1.PreserveInstanceAnnotation]
if exists {
return false
}

if r.nodeName == "" || machine.Status.NodeRef == nil {
return true
}
Expand Down