Skip to content

Commit b373a03

Browse files
authored
Fix controller not timeouting on start hook failure (#222)
Not sure why the check order was wrong in the first place. Timeout condition is now checked *before* checking start job execution.
1 parent 15c9b2a commit b373a03

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

controllers/upgradejob_controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,6 @@ func (r *UpgradeJobReconciler) Reconcile(ctx context.Context, req ctrl.Request)
179179
func (r *UpgradeJobReconciler) reconcileStartedJob(ctx context.Context, uj *managedupgradev1beta1.UpgradeJob) (ctrl.Result, error) {
180180
l := log.FromContext(ctx).WithName("UpgradeJobReconciler.reconcileStartedJob")
181181

182-
cont, err := r.executeHooks(ctx, uj, managedupgradev1beta1.EventStart, noTrackingKey, eventInfoWithReason(managedupgradev1beta1.UpgradeJobReasonStarted), time.Time{})
183-
if err != nil {
184-
return ctrl.Result{}, err
185-
}
186-
if !cont {
187-
return ctrl.Result{}, nil
188-
}
189-
190182
if r.timeSinceStartAfter(uj) > uj.Spec.UpgradeTimeout.Duration {
191183
r.setStatusCondition(&uj.Status.Conditions, metav1.Condition{
192184
Type: managedupgradev1beta1.UpgradeJobConditionFailed,
@@ -197,6 +189,14 @@ func (r *UpgradeJobReconciler) reconcileStartedJob(ctx context.Context, uj *mana
197189
return ctrl.Result{}, r.Status().Update(ctx, uj)
198190
}
199191

192+
cont, err := r.executeHooks(ctx, uj, managedupgradev1beta1.EventStart, noTrackingKey, eventInfoWithReason(managedupgradev1beta1.UpgradeJobReasonStarted), time.Time{})
193+
if err != nil {
194+
return ctrl.Result{}, err
195+
}
196+
if !cont {
197+
return ctrl.Result{}, nil
198+
}
199+
200200
var version configv1.ClusterVersion
201201
if err := r.Get(ctx, types.NamespacedName{
202202
Name: r.ManagedUpstreamClusterVersionName,

0 commit comments

Comments
 (0)