Skip to content

Commit

Permalink
allow machinesets that have clusters to continue reconciliation (kube…
Browse files Browse the repository at this point in the history
…rnetes-sigs#836)

* allow machineset that have clusters to continue reconciliation

* machinedeployment controller also
  • Loading branch information
ntfrnzn authored and serbrech committed Apr 8, 2019
1 parent 757dd19 commit 2c71a0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions pkg/controller/machinedeployment/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ func (r *ReconcileMachineDeployment) reconcile(ctx context.Context, d *v1alpha1.
}

// Add foregroundDeletion finalizer if MachineDeployment isn't deleted and linked to a cluster.
if cluster != nil && d.ObjectMeta.DeletionTimestamp.IsZero() {
if !util.Contains(d.Finalizers, metav1.FinalizerDeleteDependents) {
d.Finalizers = append(d.ObjectMeta.Finalizers, metav1.FinalizerDeleteDependents)
}
if cluster != nil &&
d.ObjectMeta.DeletionTimestamp.IsZero() &&
!util.Contains(d.Finalizers, metav1.FinalizerDeleteDependents) {

d.Finalizers = append(d.ObjectMeta.Finalizers, metav1.FinalizerDeleteDependents)

if err := r.Client.Update(context.Background(), d); err != nil {
klog.Infof("Failed to add finalizers to MachineSet %q: %v", d.Name, err)
Expand Down
9 changes: 5 additions & 4 deletions pkg/controller/machineset/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ func (r *ReconcileMachineSet) reconcile(ctx context.Context, machineSet *cluster
}

// Add foregroundDeletion finalizer if MachineSet isn't deleted and linked to a cluster.
if cluster != nil && machineSet.ObjectMeta.DeletionTimestamp.IsZero() {
if !util.Contains(machineSet.Finalizers, metav1.FinalizerDeleteDependents) {
machineSet.Finalizers = append(machineSet.ObjectMeta.Finalizers, metav1.FinalizerDeleteDependents)
}
if cluster != nil &&
machineSet.ObjectMeta.DeletionTimestamp.IsZero() &&
!util.Contains(machineSet.Finalizers, metav1.FinalizerDeleteDependents) {

machineSet.Finalizers = append(machineSet.ObjectMeta.Finalizers, metav1.FinalizerDeleteDependents)

if err := r.Client.Update(context.Background(), machineSet); err != nil {
klog.Infof("Failed to add finalizers to MachineSet %q: %v", machineSet.Name, err)
Expand Down

0 comments on commit 2c71a0e

Please sign in to comment.