Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 capd: fix nil pointer in dockermachinepool controller #10876

Merged
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
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
Loading