Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageRepository status.lastScanResult.latestTags not sorted acc. to semver #443

Open
heubeck opened this issue Sep 14, 2023 · 4 comments
Open

Comments

@heubeck
Copy link

heubeck commented Sep 14, 2023

Hey there,
thank you very much for you great effort with flux.

Now the 'bug' 😇 : 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?

@darkowlzz
Copy link
Contributor

Hi, it seems there's a misunderstanding of what this field is for. Based on it's origin, refer #311 (comment), 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?

@heubeck
Copy link
Author

heubeck commented Sep 14, 2023

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?

@darkowlzz
Copy link
Contributor

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.

@heubeck
Copy link
Author

heubeck commented Sep 14, 2023

you're right.
so maybe only the rename of latestTags to not confuse me anymore ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants