Skip to content

Commit

Permalink
Check Strategy is not nil in MachineDeployments to avoid panic
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Apr 23, 2021
1 parent 46dc43a commit 7a67d6a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/machinedeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ func (r *MachineDeploymentReconciler) reconcile(ctx context.Context, cluster *cl
return ctrl.Result{}, r.sync(ctx, d, msList)
}

if d.Spec.Strategy == nil {
return ctrl.Result{}, errors.Errorf("missing MachineDeployment strategy")
}

if d.Spec.Strategy.Type == clusterv1.RollingUpdateMachineDeploymentStrategyType {
if d.Spec.Strategy.RollingUpdate == nil {
return ctrl.Result{}, errors.Errorf("missing MachineDeployment settings for strategy type: %s", d.Spec.Strategy.Type)
}
return ctrl.Result{}, r.rolloutRolling(ctx, d, msList)
}

Expand Down

0 comments on commit 7a67d6a

Please sign in to comment.