Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit d0b6174

Browse files
committed
Separate dispatching and running timeouts
1 parent 4e53bef commit d0b6174

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

internal/controller/appwrapper_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request)
155155
case mcadv1beta1.Requeuing:
156156
// delete wrapped resources
157157
if r.deleteResources(ctx, appWrapper) != 0 {
158-
if isSlowDeletion(appWrapper) {
158+
if isSlowRequeuing(appWrapper) {
159159
// give up requeuing and fail instead
160160
return r.updateStatus(ctx, appWrapper, mcadv1beta1.Failed)
161161
} else {
@@ -167,7 +167,7 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request)
167167

168168
case mcadv1beta1.Dispatching:
169169
// dispatching is taking too long?
170-
if isSlowCreation(appWrapper) {
170+
if isSlowDispatching(appWrapper) {
171171
// set requeuing or failed status
172172
return r.requeueOrFail(ctx, appWrapper)
173173
}
@@ -190,7 +190,7 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request)
190190
if err != nil {
191191
return ctrl.Result{}, err
192192
}
193-
if counts.Failed > 0 || isSlowCreation(appWrapper) && (counts.Other > 0 || counts.Running < int(appWrapper.Spec.MinPods)) {
193+
if counts.Failed > 0 || isSlowRunning(appWrapper) && (counts.Other > 0 || counts.Running < int(appWrapper.Spec.MinPods)) {
194194
// set requeuing or failed status
195195
return r.requeueOrFail(ctx, appWrapper)
196196
}

internal/controller/resource_manager.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,17 @@ func (r *AppWrapperReconciler) monitorPods(ctx context.Context, appWrapper *mcad
117117
return counts, nil
118118
}
119119

120-
// Is dispatch too slow?
121-
func isSlowCreation(appWrapper *mcadv1beta1.AppWrapper) bool {
122-
return metav1.Now().After(appWrapper.Status.LastDispatchTime.Add(creationTimeout))
120+
// Is requeuing too slow?
121+
func isSlowRequeuing(appWrapper *mcadv1beta1.AppWrapper) bool {
122+
return metav1.Now().After(appWrapper.Status.LastRequeuingTime.Add(requeuingTimeout))
123123
}
124124

125-
// Is requeuing too slow?
126-
func isSlowDeletion(appWrapper *mcadv1beta1.AppWrapper) bool {
127-
return metav1.Now().After(appWrapper.Status.LastRequeuingTime.Add(deletionTimeout))
125+
// Is dispatching too slow?
126+
func isSlowDispatching(appWrapper *mcadv1beta1.AppWrapper) bool {
127+
return metav1.Now().After(appWrapper.Status.LastDispatchTime.Add(dispatchingTimeout))
128+
}
129+
130+
// Is running too slow?
131+
func isSlowRunning(appWrapper *mcadv1beta1.AppWrapper) bool {
132+
return metav1.Now().After(appWrapper.Status.LastDispatchTime.Add(runningTimeout))
128133
}

internal/controller/timings.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ const (
3030

3131
cacheConflictTimeout = 5 * time.Minute // when to give up on a cache conflict
3232

33-
// Timeouts for the creation and deletion of wrapped resources and pods
34-
creationTimeout = 5 * time.Minute // minimum wait before aborting an incomplete resource/pod creation
35-
deletionTimeout = 5 * time.Minute // minimum wait before aborting an incomplete resource deletion
33+
// Timeouts
34+
requeuingTimeout = 2 * time.Minute // minimum wait before aborting Requeuing
35+
dispatchingTimeout = 2 * time.Minute // minimum wait before aborting Dispatching
36+
runningTimeout = 5 * time.Minute // minimum wait before aborting Running
3637

3738
// RequeueAfter delays
3839
// This is the maximum delay before the next reconciliation event but reconciliation

0 commit comments

Comments
 (0)