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

Latest version in HelmRelease does not pull expected version from OCI Registry #768

Closed
1 task done
tparnold opened this issue Jun 7, 2022 · 2 comments · Fixed by #769
Closed
1 task done

Latest version in HelmRelease does not pull expected version from OCI Registry #768

tparnold opened this issue Jun 7, 2022 · 2 comments · Fixed by #769
Assignees
Labels
area/helm Helm related issues and pull requests area/oci OCI related issues and pull requests bug Something isn't working

Comments

@tparnold
Copy link

tparnold commented Jun 7, 2022

Describe the bug

The registry contains helm charts the versions 0.9.0, 0.10.0, 0.11.0, ...
When I configure a HelmRelease with the version "0.*", the helm chart with version 0.9.0 is pulled. Expecting the highest version to be pulled.

HelmRelease:

spec:
  interval: 1m
  chart:
    spec:
      chart: demoapp
      version: "0.*"
      sourceRef:
        kind: HelmRepository
        name: my-helm-repo
        namespace: gitops-flux-configuration
      interval: 1m

The problem ONLY occurs if the HelmRepository references an OCI Registry.
For testing purposes I switched to a dedicated Helm Repository in artifactory and the expected latest version was pulled.

I tried several different values for version in the HelmRelease resource:

version: "0.*"
version: "0.x.x"
version: "*"

All with the same result: Version 0.9.0 of the helm chart is pulled.

I encountered the problem last week with the new release of the source controller and have the same result after updating to the Flux v0.31.0 release today.

Can anyone confirm this behavior?

Steps to reproduce

Setup HelmRelease and HelmRepository resources to pull a version range from an OCI registry.
Provide multiple versions of the helm chart in the docker registry e.g. 0.9.0, 0.10.0, ...

Expected behavior

Latest version of the helm chart is pulled. (i.e., the one with the highest version)

Screenshots and recordings

No response

OS / Distro

N/A

Flux version

v0.31.0

Flux check

N/A

Git provider

No response

Container Registry provider

Artifactory

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@stefanprodan
Copy link
Member

stefanprodan commented Jun 7, 2022

We use Helm's semver parser, if you do helm pull oci://<chart-URL> --version="0.x" does it pull the right version?

@hiddeco hiddeco added the area/helm Helm related issues and pull requests label Jun 7, 2022
@tparnold
Copy link
Author

tparnold commented Jun 7, 2022

Thanks for the quick reply.
The command helm pull oci://<chart-URL> --version="0.x" pulls the expected version.

I had a look at getLastMatchingVersionOrConstraint in oci_chart_repository.go.
It seems the semver parser is used to reduce the versions received from the repository by applying the pattern specified in the HelmRelease resource.
The result is then a new list of versions, which is sorted (by string comparison?) and index 0 is returned.

If my interpretation is correct and a string comparator is used to sort the list of 0.9, 0.10, ... we get exactly the result I observed.

@makkes makkes added the area/oci OCI related issues and pull requests label Jun 7, 2022
@stefanprodan stefanprodan transferred this issue from fluxcd/flux2 Jun 7, 2022
@stefanprodan stefanprodan added the bug Something isn't working label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm Helm related issues and pull requests area/oci OCI related issues and pull requests bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants