Skip to content

feat(generate): fan promote deploys with retries out per environment - #709

Open
reka18 wants to merge 5 commits into
mainfrom
fix/promote-per-env-retries-626
Open

reka18 wants to merge 5 commits into
mainfrom
fix/promote-per-env-retries-626

Conversation

@reka18

@reka18 reka18 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

What was wrong

retries is documented for each deploys entry, but the promote generator ignored it. A promotion ran each deploy exactly once, while a trunk run retried it. Promote is the production path, so a transient deploy failure cost the most exactly where the retry was missing.

The orchestrate retry ladder doesn't transfer as is. A promote deploy that declares inputs is a matrix job across environments, and a matrix exposes one aggregate result. A caller-side retry gated on that result would redeploy the environments that already succeeded.

What changed

  • Per-environment retries. A deploy that declares inputs and sets retries > 0 replaces its promote matrix with one job per promotion target (for example deploy-web-to-staging). Each job reads its resolved inputs from new preflight outputs. Each gets its own retry chain, so only the environment that failed is retried. The -to- infix avoids a collision with the existing deploy-<name>-prod job.
  • Plain ladders where there's no fan-out. The single no-inputs deploy job and the prod deployment job get plain retry ladders.
  • One copy of the retry shim. It's extracted from the orchestrate generator and shared.
  • Every result sink judges the effective result across environments and attempts:
    • the rollback gate fires only when an environment's chain is exhausted, not when a retry rescued it;
    • DEPLOY_RESULT_<NAME> stays one value (failure, success or skipped), so the finalize gate works as before;
    • the native deployments status follows each chain.
  • retries: 0 or unset produces byte-identical output. Every new path is gated on retries > 0, and the baseline goldens don't move.
  • on_failure stays abort-only and run_policy stays trunk-only for promote. Promote has no dependency skips for run_policy to act on, and its force input is already the continue-past-failure control. The docs say so.
  • Docs: manifest.md, callbacks.md, guides/promote.md, generated-workflows.md and the coverage matrix.

Rebased onto #705

#705 gated promote's dry_run passthrough on the callee's declared inputs. This branch moves the deploy with: blocks into shared writers, so #705's rule now lives in those writers, and the new per-environment with: block follows the same rule.

How it's tested

  • go build, go vet, gofmt and go test ./... pass. The new promote_retry_test.go pins:
    • the per-environment fan-out and its retry chains;
    • each result sink's effective result;
    • the preflight outputs, run against jq;
    • the byte-identical retries: 0 boundary.
  • Finalize tests drive the three DEPLOY_RESULT values through the CLI gate.
  • New actionlint feature-matrix case: promote_per_env_retries.
  • New e2e scenario: promote/promote-retries-exhaustion.yaml. It exhausts one environment's chain and checks that finalize holds the pointer. act stops after a failed reusable-workflow job, so the rollback job's own run and the rescue path are checked at the trigger boundary and in unit tests instead. It needs Docker, so CI runs it; it hasn't run locally yet.

Closes #626

…sinks

Add internal/generate/promote_retry_test.go ahead of the #626 generator
change, pinning the chosen design end to end:

- a deploy with declared inputs and retries > 0 replaces its promote
  matrix with one job per promotion target (every declared environment
  except the first), gated on preflight's deploy_<name>_envs list, with
  its with: block reading per-environment resolved-input JSON;
- each per-environment job gets an orchestrate-style retry chain gated
  on its predecessor failing, as do the single no-inputs deploy job and
  the prod deployment job;
- every result sink judges the effective result across environments and
  attempts: the rollback gate (aggregate success, exhaustion with rescue
  exemption), DEPLOY_RESULT_<NAME> as one three-way aggregate value
  (failure/success/skipped), and the native deployments status;
- the build-matrices step emits the envs list and per-environment
  inputs (executed against jq, mirroring the matrix script tests);
- skipped-leg semantics and the byte-frozen retries 0 boundary (an
  explicit retries: 0 is byte-identical to an omitted retries).

Rewrite the two pinned inertness tests rather than deleting them:
DoesNotEmitRetryLadder becomes EmitsRetryLadder with the design
rationale, and RetriesDoNotPerturbOutput keeps its byte-compare method
at the retries 0 versus unset boundary. Add CLI-side tests driving the
three aggregate values through the finalize gate (pointer hold, deploy
row recording, all-skipped refusal).

Closes #626

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Wire retries into the promote workflow (#626), to the design that keeps
every retry scoped to the one environment whose attempt failed:

- Extract writeRetryShimJob from the orchestrate generator's writeRetryJob
  so the promote ladders reuse the single copy of the shim emission: the
  !cancelled() status-function gate, the predecessor chaining, the name
  shape, needs: construction, uses:/with:/secrets ordering.
- A deploy with declared inputs and retries > 0 replaces its promote
  matrix with one job per promotion target (every declared environment
  except the first), gated on preflight's new deploy_<name>_envs output,
  each with: block reading per-environment resolved-input JSON from the
  new deploy_<name>_inputs_<env> outputs. A matrix exposes one aggregate
  result, so a caller-side shim would redeploy every leg; per-environment
  jobs are the only caller-side shape that can retry just the failed
  environment. The job id carries a -to- infix (deploy-web-to-staging)
  because the pre-existing deploy-<name>-prod job would otherwise collide
  with a per-environment job for an environment literally named prod.
- The single no-inputs deploy job and the prod deployment job are already
  single-environment and get plain ladders directly.
- The build-matrices step emits the fan-out contract (the envs list and
  per-environment inputs) instead of the matrix when retries is set; the
  resolved-input computation is shared verbatim with the matrix path.
- Rewire every result sink to the effective result across environments
  and attempts, via the shared retryShimJobIDs/effectiveSuccessCond/
  effectiveFailureOrCancelledCond helpers: the rollback gate fires only
  when some environment's chain is exhausted and judges the deploy's own
  success on the aggregate across its chains; DEPLOY_RESULT_<NAME> stays
  one value (failure/success/skipped) that drives the finalize CLI gate
  exactly as the per-job result did; the native deployments status judges
  each chain's effective result.
- retries 0 or unset emits byte-identical output everywhere: every new
  path is gated on retries > 0, and the byte-identical baseline goldens
  do not move.
- on_failure stays abort-only and run_policy stays orchestrate-scoped
  (promote has no dependency skips to bind run_policy to; the force
  dispatch input is promote's continue-past-failure control).
- Add the promote_per_env_retries actionlint feature-matrix case so real
  GitHub's parse of the fan-out (fromJSON with: reads, contains() gates,
  shim chaining, needs:/if: agreement across the aggregate sinks) is
  under permanent guard.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…dary

Add promote/promote-retries-exhaustion.yaml, the executing scenario for
the promote retry fan-out (#626). app declares manifest inputs plus
retries: 1, so the promote fans it out per promotion target; a marker
commit arms the app callback to fail test deploys, so the second
dev-to-test promote exhausts app's test chain and the run concludes in
failure with the asymmetric deploy outcome (infra deployed, app failed)
that is the sole rollback-on-failure trigger. Finalize holds the test
pointer at the pre-promote SHA through the DEPLOY_RESULT aggregate.

The scenario states its boundaries honestly, the way
73-deploy-retries.yaml does: act v0.2.99 skips every later stage after a
failed reusable-workflow job, so the rollback job's own execution and
the fail-then-rescue path are not observable here and are asserted
through the trigger boundary (plus the emitted YAML, unit tests, and the
actionlint feature matrix) instead. The emitted assertions are verified
against real generated output for this exact manifest.

Register the scenario under the promote kind in the coverage registry.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…k-only

Update the manifest reference's Policy fields to the #626 design: retries
now applies to trunk runs and promotions alike, with a note explaining
the per-environment fan-out (deploy-<name>-to-<env> jobs, one ladder per
promotion target), the effective-result sinks (rollback exhaustion,
DEPLOY_RESULT aggregate, deployments status), and the two stated
consequences (rollout fail_fast/max_parallel do not apply while retries
fans a deploy out; the publish marker runs no deploy legs).

run_policy and on_failure remain orchestrate-only, with the reason:
promote has no dependency skips to bind run_policy to, and the force
dispatch input is promote's continue-past-failure control. Mirror the
scope in the callbacks reference, the promote guide, the
generated-workflows deploy strategy block, and the coverage matrix, and
add the CHANGELOG entry.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…out target

Review findings on the #626 branch, fixed:

- A single-environment manifest fed to the promote generator (reachable
  per component through an environments: override, since both the
  generate command and Plan gate only the root config on
  IsSingleEnvironment) left an inputs deploy with retries with ZERO
  promotion chains, rendering a malformed DEPLOY_RESULT expression and a
  malformed rollback success line. Introduce perEnvFanOut as the single
  predicate for the fan-out (retries, declared inputs, and at least one
  environment to promote into) and gate the deploy jobs, the preflight
  outputs, and the build-matrices section on it: with no promotion
  target the deploy keeps the matrix form, whose chain carries no shims
  and whose sinks keep the bare forms. The sinks now derive ladder
  presence from the chain model (chainsHaveLadder) rather than the raw
  retries field, so the corner is byte-identical to a retry-free
  manifest. Pinned by TestPromoteRetry_SingleEnvironmentKeepsMatrix,
  both directly and through promoteTargets for the component route.
- The prod-deployment ladder's chain was constructed inline at three
  sites; extract prodChain as the single source for its job id and
  retry binding, and collapse the native-deployments loop onto
  deployChains (byte-identical output).
- State the two behavior notes for retries adopters in the CHANGELOG:
  the publish marker runs no deploy leg where the matrix previously
  invoked the callback with environment="release" (no recorded state
  ever depended on it), and a single-environment component keeps the
  matrix form.
Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>

This branch has not been deployed

No deployments
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.

promote: retries and on_failure are not emitted into promote.yaml

1 participant