@@ -56,6 +56,10 @@ func NewActuator(params ActuatorParams) *Actuator {
5656
5757// Create creates a machine and is invoked by the machine controller.
5858func (a * Actuator ) Create (ctx context.Context , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) error {
59+ if cluster == nil {
60+ return errors .Errorf ("missing cluster for machine %s/%s" , machine .Namespace , machine .Name )
61+ }
62+
5963 klog .Infof ("Creating machine %v for cluster %v" , machine .Name , cluster .Name )
6064
6165 scope , err := actuators .NewMachineScope (actuators.MachineScopeParams {Machine : machine , Cluster : cluster , Client : a .client })
@@ -77,6 +81,10 @@ func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machi
7781
7882// Delete deletes a machine and is invoked by the Machine Controller.
7983func (a * Actuator ) Delete (ctx context.Context , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) error {
84+ if cluster == nil {
85+ return errors .Errorf ("missing cluster for machine %s/%s" , machine .Namespace , machine .Name )
86+ }
87+
8088 klog .Infof ("Deleting machine %v for cluster %v." , machine .Name , cluster .Name )
8189
8290 scope , err := actuators .NewMachineScope (actuators.MachineScopeParams {Machine : machine , Cluster : cluster , Client : a .client })
@@ -101,6 +109,10 @@ func (a *Actuator) Delete(ctx context.Context, cluster *clusterv1.Cluster, machi
101109// If the Update attempts to mutate any immutable state, the method will error
102110// and no updates will be performed.
103111func (a * Actuator ) Update (ctx context.Context , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) error {
112+ if cluster == nil {
113+ return errors .Errorf ("missing cluster for machine %s/%s" , machine .Namespace , machine .Name )
114+ }
115+
104116 klog .Infof ("Updating machine %v for cluster %v." , machine .Name , cluster .Name )
105117
106118 scope , err := actuators .NewMachineScope (actuators.MachineScopeParams {Machine : machine , Cluster : cluster , Client : a .client })
@@ -123,6 +135,10 @@ func (a *Actuator) Update(ctx context.Context, cluster *clusterv1.Cluster, machi
123135
124136// Exists test for the existence of a machine and is invoked by the Machine Controller
125137func (a * Actuator ) Exists (ctx context.Context , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) (bool , error ) {
138+ if cluster == nil {
139+ return false , errors .Errorf ("missing cluster for machine %s/%s" , machine .Namespace , machine .Name )
140+ }
141+
126142 klog .Infof ("Checking if machine %v for cluster %v exists" , machine .Name , cluster .Name )
127143
128144 scope , err := actuators .NewMachineScope (actuators.MachineScopeParams {Machine : machine , Cluster : cluster , Client : a .client })
0 commit comments