Skip to content

fix(generate): invoke the configured deploy and rollback callbacks in the hotfix workflow - #696

Merged
reka18 merged 3 commits into
mainfrom
fix/hotfix-deploy-rollback-invoke-678
Dec 1, 2026
Merged

reka18 merged 3 commits into
mainfrom
fix/hotfix-deploy-rollback-invoke-678

Conversation

@reka18

@reka18 reka18 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

The deploy-<name> and rollback-<name> jobs in the generated cascade-hotfix.yaml were placeholders. Each held the target's GitHub environment: gate, printed the deploy it stood in for, and succeeded. So a green hotfix run cherry-picked, built and finalized (state, tag, release) but deployed nothing, and running the configured deploy against the hotfix merge SHA was a manual follow-up. The rollback job only printed a message too, so a failed hotfix had no automatic way back to the environment's pre-hotfix deployment.

What changed

  • Each hotfix deploy job now calls the configured deploy workflow as a reusable workflow (uses:) on the resolution pull request's merge SHA. The paired rollback job calls the same workflow on the pre-hotfix (N-1) SHA that the context job reads from the manifest, behind the existing failed-deploy gate.
  • Both caller jobs pass the callback contract's environment, sha and dry_run inputs, each only when the callee declares it, which is the rule the hotfix build jobs already follow. A cross-repo callback falls back to the standard contract set. Each callback's permissions: and secrets: apply to both lanes.
  • A uses: job can't carry a job-level environment: key. The target environment, resolved at run time, is passed as the environment input instead, and protection rules apply through the environment: key the callback declares on its own job. Promote's and rollback's deploy calls rely on the same contract.
  • Operator inputs and env_inputs are deliberately not passed on the hotfix deploy path, and the reference says so. image_tag is tracked separately.
  • The hotfix golden is regenerated. The two "known limitation" cautions are removed from the hotfix guide and the generated-workflows reference. The README, the how-it-works page and the CHANGELOG describe the new behavior.

How it's tested

  • New generator tests pin:

    • the calls themselves: uses: with the merge SHA and with the N-1 SHA;
    • when each input is passed: no inputs declared, some declared, and a cross-repo callback;
    • the boolean dry_run pass-through;
    • each callback's permissions and secrets;
    • that the placeholder echo is gone;
    • that validation still rejects inline run: deploys, so both lanes are always uses: calls.

    The updated prod-gate test pins that the environment is passed as an input, with no job-level environment: key. Five of these tests fail on main.

  • The regenerated golden and the determinism baseline match byte for byte.

  • actionlint is clean over the generated workflows, including the hotfix deploy and rollback call sites with real callback stubs.

  • A new e2e scenario, hotfix/hotfix-deploy-failure-holds-state.yaml, runs the merged-hotfix path under act. Its deploy stub fails at the merge SHA on purpose, and the scenario checks that:

    • the run fails;
    • finalize is skipped;
    • the environment pointer stays at the pre-hotfix deployment;
    • a replay of the same merged event fails the same way.

    To support this, hotfix_merged gains expect_failure, as the promote and rollback steps already have.

  • The rollback lane can't run under act. When a reusable-workflow callee fails, act v0.2.99 aborts every later stage of the parent plan, and the rollback job is a later stage. The scenario documents that limit. The rollback lane's N-1 call is pinned by the hotfix-rollback-runtime.yaml wiring assertions and the generator tests, and runs for real in the fleet.

  • go test ./..., go test -short ./... in e2e, gofmt -l . and golangci-lint all pass.

Fixes #678

… the hotfix workflow (#678)

The generated cascade-hotfix.yaml deploy and rollback jobs printed the
deploy they stood in for and succeeded, so a green hotfix run
cherry-picked, built, and finalized (state, tag, release) but never
shipped the fix unless the operator ran the configured deploy workflow
by hand.

Each deploy job now invokes the configured deploy callback as a
reusable workflow on the resolution pull request's merge commit SHA,
and each paired rollback job re-invokes the same callback keyed on the
pre-hotfix (N-1) SHA the context job resolves from the manifest, behind
the existing failed-deploy gate. Both thread the callback contract's
environment, sha, and dry_run inputs, each gated on the inputs the
callee declares -- the rule the hotfix build jobs already follow, so a
call never passes an input GitHub would reject at parse -- with a
cross-repo callback falling back to the standard contract set.
Per-callback permissions and secrets carry over to both caller jobs.

The caller jobs are uses: jobs, which cannot carry a job-level
environment: key, so the run-time-resolved target environment is
threaded as the environment input and protection rules apply through
the environment: key the callback declares on its own job, the same
contract the promote and rollback workflows' deploy calls rely on.
Every configured deploy is a reusable workflow: validation rejects
inline run:/shell: callbacks and requires workflow: (#161), so both
lanes are always uses: calls.

Operator inputs and env_inputs stay unthreaded on the hotfix deploy
path: env_inputs key on a target environment the hotfix resolves at
run time from the merged pull request's base ref, so no
generation-time value exists to emit, and no hotfix lane sources plain
inputs. The golden, the determinism deploy stub, and the two docs
caution blocks are updated with the placeholder they described gone.

Fixes #678.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…ck re-deploys the N-1 sha

The generator change had no runtime evidence: nothing a reviewer could
turn red by reverting the invocation alone. hotfix_merged gains
ExpectFailure, mirroring PromoteStep/RollbackStep, so a deliberately
failing deploy callback can prove the failure propagates to the whole
run: a success conclusion becomes the error, the step's expect.jobs and
expect_log assertions still evaluate against the stored failed run, and
state is re-synced from Gitea so a state assertion stays falsifiable
when finalize is skipped.

The new hotfix-deploy-failure-rollback.yaml scenario seeds a deploy
stub that discriminates its lanes by the sha it receives, keyed on two
markers the harness exports on every hotfix_merged run: the resolution
pull request's merge SHA and the target environment's recorded N-1 SHA.
Setup runs see neither marker and succeed; the merged-hotfix run fails
at the merge SHA on purpose and succeeds only at the N-1 SHA. The
run-level failure, the skipped finalize, the unchanged env pointer, and
each lane's log marker pin the merge-SHA deploy, the propagated
failure, and the rollback re-deploy of the N-1 sha. A replayed merge
asserts the rollback lane's marker and that the failure is
deterministic on rerun.

hotfix-prod-gate.yaml and hotfix-rollback-runtime.yaml move from
asserting the placeholder scaffolding to asserting the invocation and
sha threading, and point at the new scenario for the runtime behavior
they cannot stage.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
The new scenario's step 9 asserted a rollback-lane log marker that can
never appear. act v0.2.99 aborts a plan when a reusable-workflow callee
fails: handleFailure in pkg/runner/runner.go returns an error, and that
error stops every later stage of the parent plan. The rollback jobs are
a later stage, gated on always() &&
needs.deploy-<name>.result == 'failure', so under act the gate is never
evaluated and the rollback lane never runs. CI (run 46715232982) showed
exactly that split: step 8's deploy-failure assertions all passed and
only step 9's rollback marker was missing, on every attempt and rerun.

The scenario now asserts the trigger boundary, the same boundary
promote/promote-rollback-runtime.yaml settles for. Step 8 is unchanged:
the deploy lane is invoked at the merge sha, the run fails, finalize is
skipped, and the env pointer stays at the pre-hotfix deployment. Step 9
is a deterministic replay of the same merged event: the deploy marker
prints again, the run fails again (expect_failure), finalize is skipped
again, and state is still held. The rollback-lane marker assertion and
the stub branch that printed it are removed - the branch was unreachable
under act - and with no consumer left, the harness stops exporting the
N-1 marker on hotfix_merged runs.

The scenario is renamed to Hotfix Deploy Failure Fails the Run and
Holds State (file: hotfix-deploy-failure-holds-state.yaml) so the name
claims only what it proves, and its description documents the act limit
with the version and the mechanism, plus where the rollback lane's
proof does live: the hotfix-rollback-runtime.yaml wiring assertions,
the internal/generate tests that pin the emitted rollback call, and the
live fleet. hotfix-prod-gate.yaml and hotfix-rollback-runtime.yaml no
longer say the e2e suite executes the rollback callback at the N-1 sha
at runtime, and the harness comment that promised both lanes were
assertable through their markers is corrected the same way.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18
reka18 merged commit 48a27bb into main Dec 1, 2026
21 checks passed
@reka18
reka18 deleted the fix/hotfix-deploy-rollback-invoke-678 branch December 1, 2026 19:46
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.

hotfix: invoke the configured deploy and rollback workflows instead of echoing them

2 participants