Skip to content

Commit

Permalink
feat: abort ongoing operation when a new revision is available
Browse files Browse the repository at this point in the history
Signed-off-by: Zadkiel AHARONIAN <[email protected]>
  • Loading branch information
aslafy-z committed Nov 1, 2023
1 parent 26264b8 commit a6f15f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,14 @@ func (ctrl *ApplicationController) processRequestedAppOperation(app *appv1.Appli
ctrl.requestAppRefresh(app.QualifiedName(), CompareWithLatest.Pointer(), &retryAfter)
return
} else {
if state.Phase == synccommon.OperationRunning && app.Spec.SyncPolicy.Retry.Refresh && app.Status.Sync.Revision != state.Operation.Sync.Revision {
logCtx.Infof("A new revision is available, refreshing and terminating app, was phase: %s, message: %s", state.Phase, state.Message)
ctrl.requestAppRefresh(app.QualifiedName(), CompareWithLatest.Pointer(), nil)
state.Phase = synccommon.OperationTerminating
state.Message = "Operation forced to terminate (new revision available)"
ctrl.setOperationState(app, state)
return
}
// retrying operation. remove previous failure time in app since it is used as a trigger
// that previous failed and operation should be retried
state.FinishedAt = nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,8 @@ type RetryStrategy struct {
Limit int64 `json:"limit,omitempty" protobuf:"bytes,1,opt,name=limit"`
// Backoff controls how to backoff on subsequent retries of failed syncs
Backoff *Backoff `json:"backoff,omitempty" protobuf:"bytes,2,opt,name=backoff,casttype=Backoff"`
// Refresh indicates wether a new revision should trigger a new sync (default: false)
Refresh bool `json:"refresh,omitempty" protobuf:"bytes,3,opt,name=refresh"`
}

func parseStringToDuration(durationString string) (time.Duration, error) {
Expand Down

0 comments on commit a6f15f7

Please sign in to comment.