image-reflector-controller
image-reflector-controller copied to clipboard
ImageRepository status.lastScanResult.latestTags not sorted acc. to semver
Hey there, thank you very much for you great effort with flux.
Now the 'bug' :innocent: : my ImageRepository
status looks like:
status:
lastScanResult:
latestTags:
- 2.9.5
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.9
- 2.8.8
- 2.8.7
- 2.8.6
tagCount: 50
but actually there are newer tags 2.10.x
, also the related ImagePolicy is fine with status.latestImage: my-image:2.10.14
.
Sorting of the latestTags
is alphabetical, ref.: https://github.com/fluxcd/image-reflector-controller/blob/main/internal/controller/imagerepository_controller.go#L626
As the ImageRepository doesn't know the tag semantics, maybe sorting by freshness (image date desc) would make more sense?
Hi, it seems there's a misunderstanding of what this field is for. Based on it's origin, refer https://github.com/fluxcd/image-reflector-controller/pull/311#issuecomment-1245032179, it was added with the intention to show a sample of the latest tags that were read in the last scan. This could be used to debug the tags that were used in the ImagePolicy. For example, if an exclusion list is specified, the sample tags can be used to get an idea of the tags that will be used in ImagePolicy. But I do see that "latest" in the name creates this confusion. I think the sorting is mostly for stability of the result for the same data. As you already know, the tag semantics are not known at this level. We can call it just "tags" but we need to somehow indicate these are not all the tags, there's more. Maybe "sampleTags", but I don't know if that's a better term. Do you have any suggestions?
Ah, got it.
Also see, that sorting by date isn't possible without inspecting the image, as the repo List
seems only to return tags.
You're right, the latest
made me expect new things first.
sampleTags
would match the purpose, just another idea (not quite sure how beautiful it is): how about having additional fields like latestSemver
, latestAlphabetical
, latestNumeric
(each showing only a single, the latest, tag) to reflect the different sorting algorithms available in the image-reflection-controller?
how about having additional fields like latestSemver, latestAlphabetical, latestNumeric (each showing only a single, the latest, tag) to reflect the different sorting algorithms available in the image-reflection-controller?
I'm not sure if we'd like to do such extra computation which may not be used by ImagePolicy. ImagePolicy has it's own set of filters that it applies on all the data it reads from the database of ImageRepository. The purpose of ImageRepository is only to fetch the tags which can then be used by others. If ImageRepository adds these latest sorted latest results, it'd be doing a part of the job ImagePolicy does. It may lead to a use case where someone may ask to refer an ImageRepository from ImageUpdateAutomation, instead of an ImagePolicy. That changes the overall design of the components maybe for good or bad.
you're right.
so maybe only the rename of latestTags
to not confuse me anymore ;)