Closed lgs closed 3 years ago
Thank you for reporting this issue, I definitely haven't seen it before. I had a look at your regexp in regex101 to understand what might be the trouble.
I found it explains one section of your regex is a "negative lookahead" as shown here:
According to this source, the go regexp library (which Flux depends on for handling these regular expressions) does not support negative lookaheads for reasons relating to big-O timing and performance guarantees:
https://stackoverflow.com/questions/26771592/negative-look-ahead-in-go-regular-expressions
Please let me know if this helps, or if there's anything else I can do here. It seems you'll have to use a different regexp.
You could use this simpler regex:
^(master|develop[A-Za-z]*)-(\d+)$
It seems to match all the same things you were expecting, and none of the images you didn't:
but if I understood correctly what you're trying to do, I am not sure you will be able to get the behavior that you wanted without two separate regexps. If you want master
to only be upgraded to other master
images, and develop
to develop
, then I think they will need to have their own separate image policies.
If there is a way to refer back to the current value of the existing image tag in git, then I don't know it.
So then, the final regexps I would have suggested are, separately:
^master-(\d+)$
and
^develop[A-Za-z]*-(\d+)$
I wanted to say separately, this is a really interesting pattern that you're trying to apply here, regex issues aside.
I got the idea that you're trying to apply the annotation to all HelmRelease resources with a patch. This is super smooth, if it works. I appreciate you showing us how you're using Flux (or trying to use it at least) and that the use case is one I'd like to highlight if it can be made to work, with an eye towards making enhancements to the goal of feature parity in Flux v2, (which right now still doesn't have anything quite like the fluxcd.io/automated
annotation, as I'm sure you're aware.)
Did you figure this pattern out yourself, or did you find it in a tutorial or guide? I'm curious, it's not one I've seen before, but it seems super useful. Just probing to find out more information if you're willing to volunteer it here.
Thanks again for your report and sorry that you're experiencing this issue.
Thank you @kingdonb, the team implemented your suggestion to split the regex and it works successfully.
FluxCD V1 is something that we implemented years ago and it is great. Unfortunately nowadays, is not clear for us if we can and want upgrade to FluxCD V2 or go for a completely different direction.
So far this is what we are running successfully and your help has been really appreciated by all the Team. I'll close this issue for now because your trick fix it permanently.
Describe the bug
We have image pools that starts with
master-
anddevelop*-
tags. So after every image build, we want automatically update in our flux-patch.yaml related service image tag with the newest one.We have implemented this code below with the regexp definition, but anyway when the newest images are coming, flux is updating it with the wrong images.
This is our flux-patch.yaml implementation (on GitHub):
The regex error we get can be seen here:
Steps to reproduce
Run the regex like reported in the following "Expected behavior" form field.
Expected behavior
With this
regexp ^((^master|^develop[A-Za-z]*)-(\d+)(?![A-Za-z])*)$
, we are expecting to take onlydevelop-NUMBER
,master-NUMBER
,development-NUMBER
images. So for example it should updatedevelop-15
todevelop-16
,master-5
tomaster-6
,development-10
todevelopment-11
.Here the results of auto deployment and our regular expression:
Kubernetes version / Distro / Cloud provider
Amazon EKS 1.18
Flux version
flux:1.21.0
Git provider
GitHub
Container Registry provider
Harbor
Additional context
No response
Maintenance Acknowledgement
Code of Conduct