diff --git a/internal/controllers/topology/cluster/desired_state.go b/internal/controllers/topology/cluster/desired_state.go index 0aed86b5c517..de83f4309d72 100644 --- a/internal/controllers/topology/cluster/desired_state.go +++ b/internal/controllers/topology/cluster/desired_state.go @@ -617,7 +617,7 @@ func computeMachineDeployment(ctx context.Context, s *scope.Scope, machineDeploy currentObjectRef: currentBootstrapTemplateRef, // Note: we are adding an ownerRef to Cluster so the template will be automatically garbage collected // in case of errors in between creating this template and creating/updating the MachineDeployment object - // with the reference to the ControlPlane object using this template. + // with the reference to this template. ownerRef: ownerReferenceTo(s.Current.Cluster), }) @@ -642,7 +642,7 @@ func computeMachineDeployment(ctx context.Context, s *scope.Scope, machineDeploy currentObjectRef: currentInfraMachineTemplateRef, // Note: we are adding an ownerRef to Cluster so the template will be automatically garbage collected // in case of errors in between creating this template and creating/updating the MachineDeployment object - // with the reference to the ControlPlane object using this template. + // with the reference to this template. ownerRef: ownerReferenceTo(s.Current.Cluster), }) @@ -953,6 +953,10 @@ func computeMachinePool(_ context.Context, s *scope.Scope, machinePoolTopology c cluster: s.Current.Cluster, namePrefix: bootstrapConfigNamePrefix(s.Current.Cluster.Name, machinePoolTopology.Name), currentObjectRef: currentBootstrapConfigRef, + // Note: we are adding an ownerRef to Cluster so the template will be automatically garbage collected + // in case of errors in between creating this template and creating/updating the MachinePool object + // with the reference to this template. + ownerRef: ownerReferenceTo(s.Current.Cluster), }) if err != nil { return nil, errors.Wrapf(err, "failed to compute bootstrap object for topology %q", machinePoolTopology.Name) @@ -977,6 +981,10 @@ func computeMachinePool(_ context.Context, s *scope.Scope, machinePoolTopology c cluster: s.Current.Cluster, namePrefix: infrastructureMachinePoolNamePrefix(s.Current.Cluster.Name, machinePoolTopology.Name), currentObjectRef: currentInfraMachinePoolRef, + // Note: we are adding an ownerRef to Cluster so the template will be automatically garbage collected + // in case of errors in between creating this template and creating/updating the MachinePool object + // with the reference to this template. + ownerRef: ownerReferenceTo(s.Current.Cluster), }) if err != nil { return nil, errors.Wrapf(err, "failed to compute infrastructure object for topology %q", machinePoolTopology.Name)