Skip to content

fix(ci): retry an unconfirmed ordered alias from its own job - #90

Open
Z3r0Sum wants to merge 6 commits into
mainfrom
container-image-metadata-alias-job-retry
Open

Z3r0Sum wants to merge 6 commits into
mainfrom
container-image-metadata-alias-job-retry

Conversation

@Z3r0Sum

@Z3r0Sum Z3r0Sum commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • When the container-image-metadata action cannot confirm the ordered release alias, its alert tells the reader what to do. For a missing ordered tag (tag-unavailable) and for inputs that fail validation it said "Re-run all jobs". That instruction cannot be followed: a re-run of all jobs builds the image again, the rebuild has another digest, and a registry that keeps its tags immutable refuses to push a tag that already exists. The run fails at the push and never reaches the alias.
  • The other instruction, "Re-running the failed job retries", has the same problem wherever the build and the alias share a job, which the README allowed.
  • The first repository to call this action showed this on a real runner: a re-run of its combined build-and-alias job was refused at the push.

Changes

  • One retry sentence. The alert and the error annotation now say "Re-running the failed job retries" for every result except integrity-mismatch, which keeps "A re-run cannot clear it". In the script this is one assignment in the last step, from the variable the other results already use.
  • The alias gets a job of its own, in every caller. The README's caller rules and its example now ask for two jobs. The build job calls the action once for tags, labels and annotations, and its only output is the digest. The alias job runs after it: it checks out, logs in to the registry, calls the action to generate the ordered tag and calls it again to publish and check. Re-running that job retries generation and publication and builds nothing.
  • The alias job is not marked continue-on-error. Nothing depends on it, so the jobs that depend on the build run whatever it does, and a failed alias job fails the run. That also covers a failure before the step that alerts, such as the checkout or the registry login, where no message is sent. The one exception is a workflow in which something else reads the alias job's result and alerts on it.
  • A generous time limit on the alias job. The README asks for timeout-minutes of about twice the action's two phase budgets together, which is 30 minutes for today's 905 seconds. A limit below the budgets can end the job before the step that alerts. With no limit, a job that hangs in the checkout or the registry login holds its runner for six hours.
  • The one-job shape is gone from the README. The sentence that let the publish call stay in the build job is removed.
  • Two input descriptions corrected. ordered-release-tag is returned by the generate invocation, not a pre-build one. publish-ordered-release-tag now says that a job's time limit sits above the phases it runs.

The action's phases, inputs, defaults, outputs, steps and conditions are unchanged.

What this looks like in a PR

A caller's alias job, after this change:

ordered-release-alias:
  runs-on: ubuntu-latest
  needs: build
  timeout-minutes: 30
  permissions:
    contents: read
    # Add what your registry login needs.
  steps:
    - uses: actions/checkout@<sha>
    # Log in to the registry here.
    - name: Generate ordered release tag
      id: ordered-tag
      uses: PostHog/.github/.github/actions/container-image-metadata@<sha>
      with:
        images: ${{ env.IMAGE_REPOSITORY }}
        generate-ordered-release-tag: "true"
    - name: Publish ordered release alias
      uses: PostHog/.github/.github/actions/container-image-metadata@<sha>
      with:
        images: ${{ env.IMAGE_REPOSITORY }}
        publish-ordered-release-tag: "true"
        ordered-release-tag: ${{ steps.ordered-tag.outputs.ordered-release-tag }}
        ordered-release-digest: ${{ needs.build.outputs.digest }}
        alert-slack-bot-token: ${{ secrets.ALERT_SLACK_BOT_TOKEN }}

For a missing tag the annotation now reads tag-unavailable. Kargo creates no Freight for this build, so deploys stay on the previous build. Re-running the failed job retries. The same sentences go to Slack when a token is passed.

How to review this PR

  • action.yml: three changed places. One line of the last step's script (retry="$rerun_job" in the validation branch) and two input descriptions. A structural comparison of the parsed file against main shows nothing else.
  • README.md: read "What a caller must do" and the example under it first, then the result table row for tag-unavailable, the paragraph under the table and "Time budget". Three older sentences that assumed the tag is generated before the build were adjusted.
  • The second and third commits take one review note each on the same sentence: the caller rule first said a re-run "repairs" a failure. It retries, and it can recover from a transient failure.
  • The fourth and fifth commits take the review finding on this PR: the README first said the alias job needs no time limit. It now asks for a generous one.
  • The sixth commit replaces the two continue-on-error variants with one rule.

Not in this change, and why

  • A retry sentence of its own for a failure that a re-run repeats (a malformed input, an empty digest from the build job, a ref that is not the default branch). The message names the reason, and the README says a repeated validation failure is told apart by it. It returns if such an alert is seen and its reader re-runs in vain.
  • One call that both generates and publishes. An empty tag passed to the publish phase keeps meaning tag-unavailable, so a caller that numbers its own tags is never given the action's numbering.
  • The cause of tag-unavailable in the message. It names the result only, and the cause is in the generate step's warning in the same job's log.
  • Several image repositories built by a matrix. The example shows one image. The existing rule (one job per repository or a matrix over images) stays, and a worked matrix example waits for the first caller that needs one.
  • An automated test workflow for the action. Unchanged from the previous PR: the checks below are local, and callers' runs are the runner evidence.

How did you test this?

  • The last step of this action and of main's, extracted and run under bash with a recording curl stand-in. For tag-unavailable and a missing digest the annotation and the message body end with the new sentence here and the old one on main. For absent, unknown, integrity-mismatch, a confirmed alias and an empty result the output is byte-identical. A synthetic token appears in no captured output or argument list.
  • shellcheck -s bash on the last step: no findings before or after.
  • The README example with placeholder SHAs filled in passes actionlint, and actionlint rejects it when the alias job reads a build output that no longer exists. A script over the parsed example confirms two jobs, a digest-only build output, a build call with neither ordered flag, two calls in the alias job (generate, then publish), timeout-minutes: 30 on it and no continue-on-error.
  • The repository's two node --test suites pass.
  • On a real runner, with the action at main: the first caller's build confirmed its alias, a re-run of its combined build-and-alias job was refused at the push, and a failed job inside a green run was re-run alone, ran by itself and alerted again.
  • Not tested: this revision on a runner, a registry or Slack. That a re-run of the alias job alone reads the build job's digest output from the earlier attempt is GitHub's documented behaviour, and the first caller's move to this shape is where I'll see it. Semgrep was not run locally. The script change assigns one variable from another defined in the same script.

Rollback

  • Revert this PR. The previous sentence returns to the alert and the previous example to the README. No input or output changes either way, so a caller does not need to re-pin.

- The alert for a missing ordered tag or a failed publish validation
  now says that re-running the failed job retries, as it already did
  for an absent or unverified alias.
- The README asks callers to publish the alias from a job of its own
  after the build, which generates the tag itself and takes only the
  digest from the build job. Re-running that job builds nothing.
- The README no longer offers publishing from the build job, and the
  alias job needs no time limit of its own.
- The README now says that re-running the alias job retries generation
  and publication, and that it repairs a failure only once its cause
  has passed.
- The README now says that re-running the alias job can recover from a
  transient failure to generate the tag, publish the alias or verify
  it, instead of promising a repair.
@Z3r0Sum
Z3r0Sum marked this pull request as ready for review November 24, 2026 18:53
@Z3r0Sum
Z3r0Sum requested a review from a team as a code owner November 24, 2026 18:53
@Z3r0Sum

Z3r0Sum commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@PostHog review

@posthog

posthog Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Z3r0Sum PostHog Review is reviewing this pull request.

@Z3r0Sum Z3r0Sum added the security-review Request a security review label Nov 24, 2026
@veria-ai

veria-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@posthog-security-review-bot

posthog-security-review-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

✅ Security review complete — 8edc5dcc291d

No findings above the confidence threshold, in 4 min.

Add the security-review label to run again on the latest commit.

@posthog posthog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 8edc5dc: 1 Should fix.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

@posthog-security-review-bot posthog-security-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agent-driven security review - no findings.

@posthog-security-review-bot posthog-security-review-bot Bot removed the security-review Request a security review label Nov 24, 2026
- The README now asks callers to set a time limit on the alias job of
  at least twice the action's two budgets together, 30 minutes today.
  With no limit a job hung in the checkout or the registry login holds
  its runner for six hours.
- It also says that the other jobs run because they depend on the
  build, and that the job-level mark only keeps the run from failing.
- The README now says the 30 minute limit is about twice the two
  budgets together, which are 905 seconds, and not at least twice.
- It says a hung alias job delays the next build only where a
  concurrency group queues that run behind it.
- The README now gives one rule: the alias job is not marked, so a
  failed alias job fails the run, also when it fails before the step
  that alerts.
- The one exception is a workflow in which something else reads the
  alias job's result and alerts on it.
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.

2 participants