Skip to content

[Bug]: ImagePolicy numerical sort fails on timestamp tags (hyphen in extract) #131

Description

@HiranAdikari

Area

Other — GitOps / Flux image automation (flux/platform/<app>/base/image-automation.yaml)

Description

The ImagePolicy resources for dc-api and cloud-ui are meant to select the newest image by sorting the <YYYYMMDD>-<HHMMSS>-<sha> tag's timestamp prefix numerically. But the extract keeps the hyphen, so the value isn't a number:

filterTags:
  pattern: '^(?P<ts>\d{8}-\d{6})-[a-f0-9]+$'
  extract: '$ts'          # -> "20260528-153652" (15 chars, contains a hyphen)
policy:
  numerical: { order: asc }

image-reflector-controller then fails to sort:

ImagePolicy/dc-api  Ready=False: failed to parse invalid numeric value '20260528-153652'

Consequences

  • The ImagePolicy never resolves a latestImage, so Image Update Automation has nothing to bump — deployments stay pinned on the previous tag even though new images build and push successfully.
  • Any Kustomization that lists these ImagePolicies as health-check targets (e.g. a consumer platform Kustomization) times out reconciling indefinitely: HealthCheckFailed: timeout waiting for ImagePolicy/... status: 'InProgress'.

The code comment states the intent is "14 decimal digits we then sort numerically," but the capture group spans the hyphen and yields 15 characters.

Steps to Reproduce

  1. Build and push an image tagged <YYYYMMDD>-<HHMMSS>-<sha>.
  2. kubectl get imagepolicy dc-api -n flux-system → empty LATESTIMAGE, Ready=False: failed to parse invalid numeric value.
  3. ImageUpdateAutomation reports "repository up-to-date"; the Deployment never moves off the old tag.

Severity

Severity/Major — blocks all dc-api / cloud-ui image rollouts through GitOps.

Proposed fix

Capture date and time as separate groups and concatenate, yielding 14 pure digits the numerical policy can parse:

filterTags:
  pattern: '^(?P<ts>\d{8})-(?P<tm>\d{6})-[a-f0-9]+$'
  extract: '$ts$tm'       # -> "20260528153652"
policy:
  numerical: { order: asc }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type/BugIdentifies a bug in the project

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions