Skip to content

Commit

Permalink
capd: fix nil pointer in dockermachinepool controller
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Jul 16, 2024
1 parent 6541888 commit 6d30801
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,19 @@ func (r *DockerMachinePoolReconciler) deleteMachinePoolMachine(ctx context.Conte
// propagateMachineDeleteAnnotation returns the DockerMachines for a MachinePool and for each DockerMachine, it copies the owner
// Machine's delete annotation to each DockerMachine if it's present. This is done just in time to ensure that the annotations are
// up to date when we sort for DockerMachine deletion.
func (r *DockerMachinePoolReconciler) propagateMachineDeleteAnnotation(ctx context.Context, dockerMachineSet map[string]infrav1.DockerMachine) ([]infrav1.DockerMachine, error) {
func (r *DockerMachinePoolReconciler) propagateMachineDeleteAnnotation(ctx context.Context, dockerMachineMap map[string]infrav1.DockerMachine) ([]infrav1.DockerMachine, error) {
_ = ctrl.LoggerFrom(ctx)

dockerMachines := []infrav1.DockerMachine{}
for _, dockerMachine := range dockerMachineSet {
for _, dockerMachine := range dockerMachineMap {
machine, err := util.GetOwnerMachine(ctx, r.Client, dockerMachine.ObjectMeta)
if err != nil {
return nil, errors.Wrapf(err, "error getting owner Machine for DockerMachine %s/%s", dockerMachine.Namespace, dockerMachine.Name)
}
if machine != nil && machine.Annotations != nil {
if dockerMachine.Annotations == nil {
dockerMachine.Annotations = map[string]string{}
}
if _, hasDeleteAnnotation := machine.Annotations[clusterv1.DeleteMachineAnnotation]; hasDeleteAnnotation {
dockerMachine.Annotations[clusterv1.DeleteMachineAnnotation] = machine.Annotations[clusterv1.DeleteMachineAnnotation]
}
Expand Down

0 comments on commit 6d30801

Please sign in to comment.