Skip to content

feat: ProjectConfig API spec and ctx variable for automated rollbacks#6221

Merged
jessesuen merged 1 commit into
akuity:mainfrom
jessesuen:feat/auto-rollbacks
May 18, 2026
Merged

feat: ProjectConfig API spec and ctx variable for automated rollbacks#6221
jessesuen merged 1 commit into
akuity:mainfrom
jessesuen:feat/auto-rollbacks

Conversation

@jessesuen
Copy link
Copy Markdown
Member

@jessesuen jessesuen commented May 4, 2026

Introduces the API spec for automated rollbacks in ProjectConfig CRD, enabled like the following:

apiVersion: kargo.akuity.io/v1alpha1
kind: ProjectConfig
metadata:
  name: my-project
  namespace: my-project
spec:
  promotionPolicies:
  - stageSelector:
      name: prod
    autoRollback: {}

New AutoRollbackConfig type:

  • Defines if a Stage should automatically roll back to the last known-good (verified) Freight
  • Rollback on failed verifications is always enabled when this config is present
  • OnFailedPromotions bool field: optionally also trigger rollback when a promotion itself fails

New kargo.akuity.io/rollback annotation:

  • Applied to Promotions that were created as rollbacks to previously verified Freight
  • Used to derive the Rollback bool field in promotion context

Rollback context propagated through the promotion engine (ctx.meta.promotion.rollback):

  steps:
    - uses: xxxx
      if: ${{ !ctx.meta.promotion.rollback }}
  • promotion.Context.Rollback — set from the annotation at context construction time
  • promotion.StepContext.Rollback — passed through to individual step execution
  • meta.promotion.rollback — exposed in the expr expression environment, allowing promotion steps to branch on whether they're running in a rollback

@jessesuen jessesuen requested review from a team as code owners May 4, 2026 02:58
@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 2c82d0f
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/6a0b57d46fc489000889dfb6
😎 Deploy Preview https://deploy-preview-6221.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.05%. Comparing base (9de13ee) to head (2c82d0f).

Files with missing lines Patch % Lines
pkg/promotion/promotion.go 33.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6221   +/-   ##
=======================================
  Coverage   58.05%   58.05%           
=======================================
  Files         499      499           
  Lines       41743    41748    +5     
=======================================
+ Hits        24235    24238    +3     
- Misses      16048    16050    +2     
  Partials     1460     1460           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hairyhum
Copy link
Copy Markdown
Contributor

hairyhum commented May 4, 2026

Does it mean that the full spec would look like this?

apiVersion: kargo.akuity.io/v1alpha1
kind: ProjectConfig
metadata:
  name: my-project
  namespace: my-project
spec:
  promotionPolicies:
  - stageSelector:
      name: prod
    autoRollback:
      onFailedPromotions: true|false

Copy link
Copy Markdown
Contributor

@thomastaylor312 thomastaylor312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small, minor changes needed. Otherwise LGTM

Comment thread api/v1alpha1/project_config_types.go
State: State(promo.Status.GetState()),
Vars: promo.Spec.Vars,
Rollback: promo.Annotations[kargoapi.AnnotationKeyRollback] ==
kargoapi.AnnotationValueTrue,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be false by default unless set via something like a context option?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be false by default. It would only be true if someone/something set the kargo.akuity.io/rollback annotation to be true.

We are building the context object here, determining whether the Promotion is a rollback based on the annotation, which will be set by rollback controller upon rollback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely misread this on my first pass. This is just fine

@jessesuen jessesuen force-pushed the feat/auto-rollbacks branch from 418a790 to 8adf437 Compare May 18, 2026 09:03
@jessesuen
Copy link
Copy Markdown
Member Author

Does it mean that the full spec would look like this?

Correct.

Signed-off-by: Jesse Suen <jesse@akuity.io>
@jessesuen jessesuen force-pushed the feat/auto-rollbacks branch from 8adf437 to 2c82d0f Compare May 18, 2026 18:17
@jessesuen jessesuen added this pull request to the merge queue May 18, 2026
Merged via the queue into akuity:main with commit c7adbbd May 18, 2026
17 checks passed
@jessesuen jessesuen deleted the feat/auto-rollbacks branch May 18, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants