@@ -132,8 +132,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
132
132
log := ctrl .LoggerFrom (ctx )
133
133
134
134
// Fetch the MachineHealthCheck instance
135
- m := & clusterv1.MachineHealthCheck {}
136
- if err := r .Client .Get (ctx , req .NamespacedName , m ); err != nil {
135
+ mhc := & clusterv1.MachineHealthCheck {}
136
+ if err := r .Client .Get (ctx , req .NamespacedName , mhc ); err != nil {
137
137
if apierrors .IsNotFound (err ) {
138
138
// Object not found, return. Created objects are automatically garbage collected.
139
139
// For additional cleanup logic use finalizers.
@@ -144,22 +144,22 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
144
144
return ctrl.Result {}, err
145
145
}
146
146
147
- log = log .WithValues ("Cluster" , klog .KRef (m .Namespace , m .Spec .ClusterName ))
147
+ log = log .WithValues ("Cluster" , klog .KRef (mhc .Namespace , mhc .Spec .ClusterName ))
148
148
ctx = ctrl .LoggerInto (ctx , log )
149
149
150
- cluster , err := util .GetClusterByName (ctx , r .Client , m .Namespace , m .Spec .ClusterName )
150
+ cluster , err := util .GetClusterByName (ctx , r .Client , mhc .Namespace , mhc .Spec .ClusterName )
151
151
if err != nil {
152
152
log .Error (err , "Failed to fetch Cluster for MachineHealthCheck" )
153
153
return ctrl.Result {}, err
154
154
}
155
155
156
- if isPaused , conditionChanged , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , m ); err != nil || isPaused || conditionChanged {
156
+ // Initialize the patch helper
157
+ patchHelper , err := patch .NewHelper (mhc , r .Client )
158
+ if err != nil {
157
159
return ctrl.Result {}, err
158
160
}
159
161
160
- // Initialize the patch helper
161
- patchHelper , err := patch .NewHelper (m , r .Client )
162
- if err != nil {
162
+ if isPaused , requeue , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , mhc ); err != nil || isPaused || requeue {
163
163
return ctrl.Result {}, err
164
164
}
165
165
@@ -171,24 +171,25 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
171
171
clusterv1 .RemediationAllowedCondition ,
172
172
}},
173
173
patch.WithOwnedV1Beta2Conditions {Conditions : []string {
174
+ clusterv1 .PausedV1Beta2Condition ,
174
175
clusterv1 .MachineHealthCheckRemediationAllowedV1Beta2Condition ,
175
176
}},
176
177
}
177
178
if reterr == nil {
178
179
patchOpts = append (patchOpts , patch.WithStatusObservedGeneration {})
179
180
}
180
- if err := patchHelper .Patch (ctx , m , patchOpts ... ); err != nil {
181
+ if err := patchHelper .Patch (ctx , mhc , patchOpts ... ); err != nil {
181
182
reterr = kerrors .NewAggregate ([]error {reterr , err })
182
183
}
183
184
}()
184
185
185
186
// Reconcile labels.
186
- if m .Labels == nil {
187
- m .Labels = make (map [string ]string )
187
+ if mhc .Labels == nil {
188
+ mhc .Labels = make (map [string ]string )
188
189
}
189
- m .Labels [clusterv1 .ClusterNameLabel ] = m .Spec .ClusterName
190
+ mhc .Labels [clusterv1 .ClusterNameLabel ] = mhc .Spec .ClusterName
190
191
191
- return r .reconcile (ctx , log , cluster , m )
192
+ return r .reconcile (ctx , log , cluster , mhc )
192
193
}
193
194
194
195
func (r * Reconciler ) reconcile (ctx context.Context , logger logr.Logger , cluster * clusterv1.Cluster , m * clusterv1.MachineHealthCheck ) (ctrl.Result , error ) {
0 commit comments