fluxcd / source-controller

The GitOps Toolkit source management component
https://fluxcd.io
Apache License 2.0
239 stars 187 forks source link

no chart version found - semver range issue #442

Open psolarcz opened 3 years ago

psolarcz commented 3 years ago

Version: ghcr.io/fluxcd/source-controller:v0.15.4

I'm getting an error: no chart version found for XXX-09.20.x:

flux get all -A
NAMESPACE   NAME                                READY   MESSAGE                                                     REVISION                                    SUSPENDED
flux-system helmrepository/XXX-helm-repo-dev    True    Fetched revision: 9ddf39cf1e565edfdb96edb36465ec1b440f1a9c  9ddf39cf1e565edfdb96edb36465ec1b440f1a9c    False

NAMESPACE   NAME                            READY   MESSAGE                                         REVISION    SUSPENDED
flux-system helmchart/default-XXX-dev       False   no chart version found for XXX-09.20.x                      False

However it exist in our private repo:

helm search repo XXX --version "09.20.x"
NAME                        CHART VERSION   APP VERSION DESCRIPTION
XXX-helm-repo-dev/XXX       09.20.22        09.20.22    XXX Helm Charts

It's also present in the index.yaml file:

cat data/helmrepository/flux-system/XXX-helm-repo-dev/index.yaml
apiVersion: v1
entries:
  XXX:

  - apiVersion: v2
    appVersion: 09.20.22
    created: "2021-09-20T22:13:45.626Z"
    description: XXX Helm Charts
    digest: 0a22e6db6168ff9a297026e7623eb3ab13f2f8ea442a0d9ead25898e9b385e58
    icon: https://upload.wikimedia.org/wikipedia/commons/6/64/XXX.svg
    name: XXX
    urls:
    - https://REPO_URL/artifactory/api/helm/XXX-helm-repo-dev/XXX-09.20.22.tgz
    version: 09.20.22

When I specify version explicitly it works fine, I have problem only when I use some range operator or wildcards.

Edit:

HelmRelease manifest:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: XXX-dev
  namespace: default
spec:
  chart:
    spec:
      chart: XXX
      version: "09.20.x"
      valuesFiles:
       - values.yaml
      sourceRef:
        kind: HelmRepository
        name: XXX-helm-repo-dev
        namespace: flux-system
  interval: 10m

Generated helmchart:

k get helmchart -n flux-system -o yaml
apiVersion: v1
items:
- apiVersion: source.toolkit.fluxcd.io/v1beta1
  kind: HelmChart
  metadata:
    creationTimestamp: "2021-09-21T11:07:02Z"
    finalizers:
    - finalizers.fluxcd.io
    generation: 1
    name: default-XXX-dev
    namespace: flux-system
    resourceVersion: "20314135"
    uid: 05102c57-84d5-42c9-8c74-8e7fa1f91b7e
  spec:
    chart: XXX
    interval: 10m0s
    sourceRef:
      kind: HelmRepository
      name: XXX-helm-repo-dev
    valuesFiles:
    - values.yaml
    version: 09.20.x
  status:
    conditions:
    - lastTransitionTime: "2021-09-21T11:07:12Z"
      message: no chart version found for XXX-09.20.x
      reason: ChartPullFailed
      status: "False"
      type: Ready
    observedGeneration: 1
psolarcz commented 3 years ago

I found source of a problem - our version was incorrect - 09.20.22 should not have leading 0.

This was returning an error:

Version segment starts with 0

Not sure if this is expected behaviour that there is no error, for sure it makes troubleshooting more difficult :)

tarasbsbr commented 3 years ago

@psolarcz I believe that's because 09.20.22 is not a valid semver: https://regex101.com/r/vkijKf/1/

Found your issue while also playing around with chart's dev version. #205 and #410 were a big help for me, I think something like this will work: 0.0.0-09-20-22

https://play.golang.org/p/Tiy3DQiR8La https://github.com/Masterminds/semver#checking-version-constraints

joaocc commented 1 month ago

Hi We are encountering somewhat similar issues on HelmRepository, but this time with larger numbers. It seems something like 3.1008.240831 is accepted but 3.1008.2409008 is not. I tried looking into the code to see if there is any truncation, but could not find it. Semver code seems to parse each of the 3 elements as uint64. Any hint would be appreciated.