Skip to content

Commit c08d962

Browse files
author
kumar gopal
committed
fix(flux): switch pve-nut image policy to numerical run-number ordering
The pve-nut ImagePolicy used `alphabetical desc` over bare 7-char git SHA tags, which is structurally unsound: SHAs are random hex, so the "latest" tag is whichever sorts highest by first hex char, not whichever is newest. With tags [e6e2d9b, 9d5fdfe, 5cde4ad] in ghcr today, the policy would pick e6e2d9b — the OLDEST commit (Feb 16) — as "latest" and roll the deploy back, undoing today's SKIP_CAMERAS fix. Switch the build to emit <run_number>-<short_sha> tags and the policy to numerical-asc with extract '\$1', matching the pattern already used by frigate-health-checker. Also add the workflow file to its own trigger paths so workflow edits rebuild. The current image tag in job-deploy.yaml (5cde4ad) doesn't match the new pattern, so the ImagePolicy will hold off updates until the build triggered by this commit publishes a matching tag. Refs #187
1 parent 9d5fdfe commit c08d962

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

.github/workflows/build-pve-nut.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
paths:
66
- 'scripts/pve-nut/**'
7+
- '.github/workflows/build-pve-nut.yaml'
78
branches:
89
- master
910
workflow_dispatch:
@@ -30,21 +31,19 @@ jobs:
3031
username: ${{ github.actor }}
3132
password: ${{ secrets.GITHUB_TOKEN }}
3233

33-
- name: Extract metadata
34-
id: meta
35-
uses: docker/metadata-action@v5
36-
with:
37-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38-
tags: |
39-
# Use only SHA tags for reproducibility - never push 'latest'
40-
type=sha,prefix=,format=short
41-
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/pve-nut-v') }}
42-
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/pve-nut-v') }}
34+
- name: Set short SHA
35+
id: vars
36+
run: echo "sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
4337

4438
- name: Build and push
4539
uses: docker/build-push-action@v6
4640
with:
4741
context: scripts/pve-nut
4842
push: true
49-
tags: ${{ steps.meta.outputs.tags }}
50-
labels: ${{ steps.meta.outputs.labels }}
43+
# Tag format: <run_number>-<short_sha>. The run_number prefix lets the
44+
# Flux ImagePolicy sort numerically (newest build wins) — earlier we
45+
# used bare 7-char SHAs with alphabetical-desc, which is unsound for
46+
# git SHAs (e.g. 'e6e2d9b' beat '9d5fdfe' purely on first hex char,
47+
# making the OLDEST commit "latest"). Matches the pattern used by
48+
# frigate-health-checker.
49+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.run_number }}-${{ steps.vars.outputs.sha_short }}

gitops/clusters/homelab/flux-system/image-automation-pve-nut.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ spec:
1919
imageRepositoryRef:
2020
name: pve-nut
2121
filterTags:
22-
# Match only git SHA tags (7 chars) - never use 'latest' for reproducibility
23-
pattern: '^[a-f0-9]{7}$'
22+
# Match build-sha tags (e.g. 42-abc1234) and extract the build number for
23+
# ordering. Alphabetical-desc on bare 7-char SHAs is unsound — see
24+
# build-pve-nut.yaml for the rationale.
25+
pattern: '^(\d+)-[a-f0-9]{7}$'
26+
extract: '$1'
2427
policy:
25-
alphabetical:
26-
# Use descending order to get newest SHA (alphabetically later = newer commit)
27-
order: desc
28+
numerical:
29+
order: asc
2830
---
2931
apiVersion: image.toolkit.fluxcd.io/v1beta2
3032
kind: ImageUpdateAutomation

0 commit comments

Comments
 (0)