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 Sep 28, 2023
1 parent 80d1bb8 commit 0713719
Show file tree
Hide file tree
Showing 11 changed files with 961 additions and 669 deletions.
4 changes: 4 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8472,6 +8472,10 @@
"description": "Limit is the maximum number of attempts for retrying a failed sync. If set to 0, no retries will be performed.",
"type": "integer",
"format": "int64"
},
"refresh": {
"type": "boolean",
"title": "Refresh indicates wether a new revision should trigger a new sync. Default to false"
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,12 @@ func (ctrl *ApplicationController) processRequestedAppOperation(app *appv1.Appli
// Get rid of sync results and null out previous operation completion time
state.SyncResult = nil
}
} 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, terminating app, was phase: %s, message: %s", state.Phase, state.Message)
state.Phase = synccommon.OperationTerminating
state.Message = "Operation forced to terminate (new revision available)"
ctrl.setOperationState(app, state)
return
} else {
logCtx.Infof("Resuming in-progress operation. phase: %s, message: %s", state.Phase, state.Message)
}
Expand Down
60 changes: 60 additions & 0 deletions manifests/core-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ spec:
a failed sync. If set to 0, no retries will be performed.
format: int64
type: integer
refresh:
description: Refresh indicates wether a new revision should trigger
a new sync. Default to false
type: boolean
type: object
sync:
description: Sync contains parameters for the operation
Expand Down Expand Up @@ -1627,6 +1631,10 @@ spec:
a failed sync. If set to 0, no retries will be performed.
format: int64
type: integer
refresh:
description: Refresh indicates wether a new revision should
trigger a new sync. Default to false
type: boolean
type: object
syncOptions:
description: Options allow you to specify whole app sync-options
Expand Down Expand Up @@ -2456,6 +2464,10 @@ spec:
be performed.
format: int64
type: integer
refresh:
description: Refresh indicates wether a new revision should
trigger a new sync. Default to false
type: boolean
type: object
sync:
description: Sync contains parameters for the operation
Expand Down Expand Up @@ -5463,6 +5475,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -6042,6 +6056,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -6625,6 +6641,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -7188,6 +7206,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -7775,6 +7795,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -8354,6 +8376,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -8937,6 +8961,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -9500,6 +9526,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -10073,6 +10101,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -10826,6 +10856,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -11574,6 +11606,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -12151,6 +12185,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -12738,6 +12774,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -13317,6 +13355,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -13900,6 +13940,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -14463,6 +14505,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -15036,6 +15080,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -15789,6 +15835,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -16537,6 +16585,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -17118,6 +17168,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -17688,6 +17740,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -18441,6 +18495,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -19189,6 +19245,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down Expand Up @@ -19841,6 +19899,8 @@ spec:
limit:
format: int64
type: integer
refresh:
type: boolean
type: object
syncOptions:
items:
Expand Down
12 changes: 12 additions & 0 deletions manifests/crds/application-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ spec:
a failed sync. If set to 0, no retries will be performed.
format: int64
type: integer
refresh:
description: Refresh indicates wether a new revision should trigger
a new sync. Default to false
type: boolean
type: object
sync:
description: Sync contains parameters for the operation
Expand Down Expand Up @@ -1626,6 +1630,10 @@ spec:
a failed sync. If set to 0, no retries will be performed.
format: int64
type: integer
refresh:
description: Refresh indicates wether a new revision should
trigger a new sync. Default to false
type: boolean
type: object
syncOptions:
description: Options allow you to specify whole app sync-options
Expand Down Expand Up @@ -2455,6 +2463,10 @@ spec:
be performed.
format: int64
type: integer
refresh:
description: Refresh indicates wether a new revision should
trigger a new sync. Default to false
type: boolean
type: object
sync:
description: Sync contains parameters for the operation
Expand Down
Loading

0 comments on commit 0713719

Please sign in to comment.