Skip to content

Commit e15bbc1

Browse files
committed
actually set controller reference
1 parent 209b365 commit e15bbc1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

controllers/machine_api_controllers_controller.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"k8s.io/apimachinery/pkg/runtime"
1515
ctrl "sigs.k8s.io/controller-runtime"
1616
"sigs.k8s.io/controller-runtime/pkg/client"
17+
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1718
"sigs.k8s.io/controller-runtime/pkg/log"
1819
)
1920

@@ -85,6 +86,9 @@ func (r *MachineAPIControllersReconciler) Reconcile(ctx context.Context, req ctr
8586
},
8687
},
8788
}
89+
if err := controllerutil.SetControllerReference(&imageCM, &caBundleConfigMap, r.Scheme); err != nil {
90+
return ctrl.Result{}, fmt.Errorf("failed to set controller reference: %w", err)
91+
}
8892
if err := r.Client.Patch(ctx, &caBundleConfigMap, client.Apply, client.FieldOwner("upstream-deployment-controller")); err != nil {
8993
return ctrl.Result{}, fmt.Errorf("failed to apply ConfigMap %q: %w", caBundleConfigMapName, err)
9094
}
@@ -109,7 +113,9 @@ func (r *MachineAPIControllersReconciler) Reconcile(ctx context.Context, req ctr
109113
return ctrl.Result{}, fmt.Errorf("expected Deployment, got %s/%s", toDeploy.APIVersion, toDeploy.Kind)
110114
}
111115
toDeploy.Namespace = r.Namespace
112-
116+
if err := controllerutil.SetControllerReference(&imageCM, &toDeploy, r.Scheme); err != nil {
117+
return ctrl.Result{}, fmt.Errorf("failed to set controller reference: %w", err)
118+
}
113119
if err := r.Client.Patch(ctx, &toDeploy, client.Apply, client.FieldOwner("upstream-deployment-controller")); err != nil {
114120
return ctrl.Result{}, fmt.Errorf("failed to apply Deployment %q: %w", toDeploy.GetName(), err)
115121
}

0 commit comments

Comments
 (0)