Open nguyenlinh1999 opened 1 year ago
Hi, the ImagePolicy is configured to perform numerical sorting but the filter tag doesn't seem to be correct. On checking the regex pattern in https://regex101.com/, it says that the pattern contains some error. Maybe due to which the extracted tags being passed to the numerical sort is failing to parse it as real numbers.
Based on examples from https://fluxcd.io/flux/guides/sortable-image-tags/#using-in-an-imagepolicy-object and https://fluxcd.io/flux/components/image/imagepolicies/#filter-tags , the pattern should have a named capture group to identify and extract it. Also, the pattern can be more strict to ensure that only numbers are selected by the capture group, else numerical sort will fail to parse the number again.
Based on the pattern and extract provided, ^test-[a-fA-F0-9]+-(?P<ts>[0-9]+)
may be what you need. If $ts
is expected to contain alphabets as well, numerical sort won't work.
1671684624
hi @darkowlzz. thanks your reply my docker image have tag: test-ff28ff32-1671684624 $ts => 1671684624 ('^test-[a-fA-F0-9]+-(?P.*)') this policy it work before. but today it not work. i don't have update policy or reconfig docker image tag builder
It may be that one of the newly created tags contain non-numeric values at the end of the pattern and is being selected by the capture group for numerical sorting.
Using ?P<ts>[0-9]+
would make sure only the tags that have numbers at that position get selected.
thanks you so much! @darkowlzz
i tried ^test-[a-fA-F0-9]+-(?P
But i don't know.!
before i using pattern: '^test-[a-fA-F0-9]+-(?P
I think I found a reproducible example of this that has given me some insight which I hope helps the maintainers in solving this. It seems like the issue is isolated to the behavior of policy.numerical
and its handling of capture groups that are not numerical - even if the capture group is not involved in the extraction.
I received the error failed to parse invalid numeric value 'rc'
with the following configuration, which was resolved when i changed to policy.semver
:
# failed in extracting rc2024.03.13.0-12345 or v2024.03.13.0-12345
filterTags:
pattern: (^rc|^v)(?P<year>.*)\.(?P<month>.*)\.(?P<day>.*)\.(?P<patch>.*)-(?P<job_id>.*)
extract: '$job_id'
policy:
numerical:
order: asc
versus successful semver:
# succeeds in extracting rc2024.03.13.0-12345 or v2024.03.13.0-12345
filterTags:
pattern: (^rc|^v)(?P<year>.*)\.(?P<month>.*)\.(?P<day>.*)\.(?P<patch>.*)-(?P<job_id>.*)
extract: 0.0.$job_id
policy:
semver:
range: ">=0.0.0"
Describe the bug
hi everyone. i have using fluxcd for gitops. i using Image Update Automations for auto update image. i have issue when i create Imagepolicy Resource. before it work for me. but today it have exception please help me!
Steps to reproduce
this is my manifest!
Expected behavior
and new image my build have tag: test-ff28ff32-1671684624
Screenshots and recordings
No response
OS / Distro
Ubuntu-20.04
Flux version
0.40.1
Flux check
► checking prerequisites ✗ flux 0.40.1 <2.0.0-rc.5 (new version is available, please upgrade) ✔ Kubernetes 1.21.14-eks-0a21954 >=1.20.6-0 ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v0.11.1 ✔ image-automation-controller: deployment ready ► ghcr.io/fluxcd/image-automation-controller:v0.14.0 ✔ image-reflector-controller: deployment ready ► ghcr.io/fluxcd/image-reflector-controller:v0.11.0 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v0.13.2 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v0.15.0 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v0.15.3 ► checking crds ✔ alerts.notification.toolkit.fluxcd.io/v1beta1 ✔ buckets.source.toolkit.fluxcd.io/v1beta1 ✔ gitrepositories.source.toolkit.fluxcd.io/v1beta1 ✔ helmcharts.source.toolkit.fluxcd.io/v1beta1 ✔ helmreleases.helm.toolkit.fluxcd.io/v2beta1 ✔ helmrepositories.source.toolkit.fluxcd.io/v1beta1 ✔ imagepolicies.image.toolkit.fluxcd.io/v1beta1 ✔ imagerepositories.image.toolkit.fluxcd.io/v1beta1 ✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta1 ✔ kustomizations.kustomize.toolkit.fluxcd.io/v1beta1 ✔ providers.notification.toolkit.fluxcd.io/v1beta1 ✔ receivers.notification.toolkit.fluxcd.io/v1beta1 ✔ all checks passed
Git provider
Gitlab
Container Registry provider
Gitlab container registry
Additional context
No response
Code of Conduct