mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
fix: address reviewer feedback (nil check, interface update, and context)
Signed-off-by: liketosweep <liketosweep@gmail.com>
This commit is contained in:
parent
e0dface68b
commit
ff35c941ed
2 changed files with 20 additions and 16 deletions
|
|
@ -1475,22 +1475,23 @@ func (ctrl *ApplicationController) processRequestedAppOperation(app *appv1.Appli
|
|||
logCtx.Debug("Finished processing requested app operation")
|
||||
}()
|
||||
|
||||
if app.Spec.SourceHydrator != nil && app.Operation != nil && app.Operation.Sync != nil {
|
||||
revision := app.Operation.Sync.Revision
|
||||
err := ctrl.hydrator.RollbackApp(context.Background(), app, revision)
|
||||
if err != nil {
|
||||
ctrl.setOperationState(app, &appv1.OperationState{
|
||||
Phase: synccommon.OperationFailed,
|
||||
Message: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
ctrl.setOperationState(app, &appv1.OperationState{
|
||||
Phase: synccommon.OperationSucceeded,
|
||||
Message: fmt.Sprintf("rolled back to %s", revision),
|
||||
})
|
||||
return
|
||||
}
|
||||
//added the 'ctrl.hydrator != nil' check and changed Background() to 'ctx'
|
||||
if ctrl.hydrator != nil && app.Spec.SourceHydrator != nil && app.Operation != nil && app.Operation.Sync != nil {
|
||||
revision := app.Operation.Sync.Revision
|
||||
err := ctrl.hydrator.RollbackApp(ctx, app, revision)
|
||||
if err != nil {
|
||||
ctrl.setOperationState(app, &appv1.OperationState{
|
||||
Phase: synccommon.OperationFailed,
|
||||
Message: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
ctrl.setOperationState(app, &appv1.OperationState{
|
||||
Phase: synccommon.OperationSucceeded,
|
||||
Message: fmt.Sprintf("rolled back to %s", revision),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
terminatingCause := ""
|
||||
if isOperationInProgress(app) {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ type Dependencies interface {
|
|||
|
||||
// GetCommitAuthorEmail gets the configured commit author email from argocd-cm ConfigMap.
|
||||
GetCommitAuthorEmail() (string, error)
|
||||
|
||||
// RollbackApp performs a rollback for a Source Hydrator enabled application by committing historical manifests to the sync branch.
|
||||
RollbackApp(ctx context.Context, app *appv1.Application, hydratedRevision string) error
|
||||
}
|
||||
|
||||
// Hydrator is the main struct that implements the hydration logic. It uses the Dependencies interface to access the
|
||||
|
|
|
|||
Loading…
Reference in a new issue