kargo icon indicating copy to clipboard operation
kargo copied to clipboard

Status Check Functions in conditionals

Open jessesuen opened this issue 10 months ago • 4 comments

Proposed Feature

This is a follow up to https://github.com/akuity/kargo/issues/3125.

We added conditionals, but would now like the ability to run steps based on status conditions (e.g. always, or upon failure).

GitHub Actions solves this by re-using their if clause with Status Check Functions.

Examples:

if: ${{ success() }}
if: ${{ always() }}
if: ${{ cancelled() }}
if: ${{ failure() }}

At first I felt reusing the if clause for this purpose seemed a bit too magical and preferred this to be in a separate field. From docs:

A default status check of success() is applied unless you include one of these functions

However, after thinking about this more, having it in the if clause has advantages over introducing it into another field because it can be mixed with other checks. e.g.:

if: ${{ failure() && steps.demo.conclusion == 'failure' }}

So I am in favor of GitHub's approach to this.

Motivation

This would be useful in things like notification steps

Suggested Implementation

Introduce status check functions understood in the if clause.

jessesuen avatar Mar 11 '25 18:03 jessesuen

Alternative/related proposals:

  • https://github.com/akuity/kargo/issues/2972
  • https://github.com/akuity/kargo/issues/3228

jessesuen avatar Mar 11 '25 18:03 jessesuen

I would happily close #3228 in favor of this approach.

krancour avatar Mar 12 '25 04:03 krancour

Hey all - is the proposal here to solve rollback scenarios with this too? Case I'm thinking about is -

  1. Promote to Stage A (git clone, commit, push; argo-update)
  2. Run Verification Steps(metrics check, qa test run)
  3. A Test Fails causing failed verification
  4. Run a step to redo step one with the previous freight as input - effectively a rollback

sbyrne-teck avatar Mar 31 '25 19:03 sbyrne-teck

is the proposal here to solve rollback scenarios with this too?

No, https://github.com/akuity/kargo/issues/2972 would be the issue to follow, which could automatically trigger a roll back in the case of verification failure.

jessesuen avatar Mar 31 '25 23:03 jessesuen