Fix: don't increment count in status (#2306)

This commit is contained in:
Hongchao Deng
2021-09-15 01:20:58 -04:00
committed by GitHub
parent 291f9d139e
commit d0e8418c4a
8 changed files with 2 additions and 66 deletions

View File

@@ -299,9 +299,6 @@ type WorkflowStatus struct {
Suspend bool `json:"suspend"`
Terminated bool `json:"terminated"`
// WaitCount counts the reconcile times on conditional wait
WaitCount int `json:"waitCount"`
ContextBackend *corev1.ObjectReference `json:"contextBackend,omitempty"`
Steps []WorkflowStepStatus `json:"steps,omitempty"`
}

View File

@@ -1042,15 +1042,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object
@@ -3122,15 +3117,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object

View File

@@ -710,14 +710,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object
@@ -1499,14 +1495,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object

View File

@@ -1153,15 +1153,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object

View File

@@ -1042,15 +1042,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object
@@ -3122,15 +3117,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object

View File

@@ -955,15 +955,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object
@@ -2010,15 +2005,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object

View File

@@ -1153,15 +1153,10 @@ spec:
type: boolean
terminated:
type: boolean
waitCount:
description: WaitCount counts the reconcile times on conditional
wait
type: integer
required:
- mode
- suspend
- terminated
- waitCount
type: object
type: object
type: object

View File

@@ -58,7 +58,7 @@ const (
const (
// baseWorkflowBackoffWaitTime is the time to wait before reconcile workflow again
baseWorkflowBackoffWaitTime = 100 * time.Millisecond
baseWorkflowBackoffWaitTime = 3000 * time.Millisecond
legacyResourceTrackerFinalizer = "resourceTracker.finalizer.core.oam.dev"
// resourceTrackerFinalizer is to delete the resource tracker of the latest app revision.
@@ -68,10 +68,6 @@ const (
legacyOnlyRevisionFinalizer = "app.oam.dev/only-revision-finalizer"
)
var (
exponentialBackoffBuckets = []int64{1, 2, 4, 8, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128, 128, 256, 512}
)
// Reconciler reconciles a Application object
type Reconciler struct {
client.Client
@@ -195,9 +191,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
case common.WorkflowStateTerminated:
return ctrl.Result{}, r.patchStatus(ctx, app, common.ApplicationWorkflowTerminated)
case common.WorkflowStateExecuting:
waitTime := computeBackoffWaitTime(app.Status.Workflow.WaitCount)
app.Status.Workflow.WaitCount++
return reconcile.Result{RequeueAfter: waitTime}, r.patchStatus(ctx, app, common.ApplicationRunningWorkflow)
return reconcile.Result{RequeueAfter: baseWorkflowBackoffWaitTime}, r.patchStatus(ctx, app, common.ApplicationRunningWorkflow)
case common.WorkflowStateFinished:
wfStatus := app.Status.Workflow
if wfStatus != nil {
@@ -284,13 +278,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return ctrl.Result{}, r.patchStatus(ctx, app, phase)
}
func computeBackoffWaitTime(cnt int) time.Duration {
if cnt >= len(exponentialBackoffBuckets) {
cnt = len(exponentialBackoffBuckets) - 1
}
return time.Duration(int64(baseWorkflowBackoffWaitTime) * exponentialBackoffBuckets[cnt])
}
// NOTE Because resource tracker is cluster-scoped resources, we cannot garbage collect them
// by setting application(namespace-scoped) as their owners.
// We must delete all resource trackers related to an application through finalizer logic.