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

Google Artifact Registry-based helm chart is not defaulting to latest version #6584

Closed
RGPosadas opened this issue Aug 7, 2023 · 8 comments · Fixed by #6588
Closed

Google Artifact Registry-based helm chart is not defaulting to latest version #6584

RGPosadas opened this issue Aug 7, 2023 · 8 comments · Fixed by #6588
Assignees
Labels
kind/bug An issue that reports a defect in an existing feature

Comments

@RGPosadas
Copy link

RGPosadas commented Aug 7, 2023

Describe the bug
GAR repo is not showing the latest release as default.

To Reproduce
Steps to reproduce the behavior:

  1. Have kubeapps configured to use Artifact Registry as an initial repo
    initialRepos:
      - name: gar
        url: <redacted>
        basicAuth:
          user: <redacted>
          password: <redacted>
        namespace: my-ns
        type: oci
        ociRepositories:
          - k8s-repo/my-chart
  1. On Catalog view, it is not showing the latest release
    image

  2. On Deploy view, it is also not showing the latest release

    • Note that all releases are uploaded to GAR in the correct order for the non-dev official release versions
    • From what we've noticed, the chosen version is random
    • When new releases are uploaded to GAR, it could choose a new "default" version, and it may or may not be the correct latest release
      image
  3. View kubeappsapis logs:

    • On Catalog view
    I0807 19:38:23.367869       1 packages.go:60] "+core GetAvailablePackageSummaries" cluster="default" namespace="my-ns"
    I0807 19:38:23.367979       1 server.go:201] "+helm GetAvailablePackageSummaries" cluster="default" namespace="my-ns"
    I0807 19:38:23.592364       1 repositories.go:117] "+core GetPackageRepositorySummaries" cluster="default" namespace=""
    I0807 19:38:23.592438       1 server.go:1143] +helm GetPackageRepositorySummaries [cluster:"default"]
    I0807 19:38:23.592552       1 repositories_resources.go:31] +helm getPkgRepositoryResource [&{0xc00038e6a0  {kubeapps.com v1alpha1 apprepositories}}]
    • On Deploy view, note that while it is logging (latest version), it is actually not the correct latest version
    I0807 19:39:24.829848       1 packages.go:109] "+core GetAvailablePackageDetail" cluster="default" namespace="my-ns"
    I0807 19:39:24.829919       1 server.go:287] "+helm GetAvailablePackageDetail" cluster="default" namespace="my-ns"
    I0807 19:39:24.877494       1 server.go:317] Requesting chart 'gar/k8s-repo%2Fmy-chart' (latest version) in ns 'my-ns'
    • When selecting the correct latest version:
    I0807 19:41:48.651615       1 packages.go:109] "+core GetAvailablePackageDetail" cluster="default" namespace="my-ns"
    I0807 19:41:48.651672       1 server.go:287] "+helm GetAvailablePackageDetail" cluster="default" namespace="my-ns"
    I0807 19:41:48.708732       1 server.go:320] Requesting chart 'gar/k8s-repo%2/Fmy-chart' (version 4.0.0-cct-1200) in ns 'my-ns'

Expected behavior
We expect the latest semver version of a chart to be the default version when deploying a release.

Desktop (please complete the following information):

  • Version: 2.8.0

  • Kubernetes version: v1.24.12-gke.1000

  • Config:

    config.json
    {
      "kubeappsCluster": "default",
      "kubeappsNamespace": "apps",
      "helmGlobalNamespace": "apps",
      "carvelGlobalNamespace": "kapp-controller-packaging-global",
      "appVersion": "v2.8.0",
      "authProxyEnabled": true,
      "oauthLoginURI": "/oauth2/start",
      "oauthLogoutURI": "/oauth2/sign_out",
      "authProxySkipLoginPage": false,
      "featureFlags": {"apiOnly":{"enabled":false,"grpc":{"annotations":{"nginx.ingress.kubernetes.io/backend-protocol":"GRPC"}}},"operators":false,"schemaEditor":{"enabled":false}},
      "clusters": ["default"],
      "theme": "",
      "remoteComponentsUrl": "",
      "customAppViews": [],
      "skipAvailablePackageDetails": false,
      "createNamespaceLabels": {}
    }
  • Plugins:

    plugins.conf
     {
       "core": {
         "packages": {
           "v1alpha1": {
             "timeoutSeconds": 300,
             "versionsInSummary": {
               "major": 3,
               "minor": 6,
               "patch": 8
             }
           }
         }
       },
       "flux": {
         "packages": {
           "v1alpha1": {
             "defaultUpgradePolicy": "none",
             "noCrossNamespaceRefs": false
           }
         }
       },
       "helm": {
         "packages": {
           "v1alpha1": {
             "globalPackagingNamespace": ""
           }
         }
       },
       "kappController": {
         "packages": {
           "v1alpha1": {
             "defaultAllowDowngrades": false,
             "defaultUpgradePolicy": "none",
             "globalPackagingNamespace": "kapp-controller-packaging-global"
           }
         }
       },
       "resources": {
         "packages": {
           "v1alpha1": {
             "trustedNamespaces": {
               "headerName": "",
               "headerPattern": ""
             }
           }
         }
       }
     }
@RGPosadas RGPosadas added the kind/bug An issue that reports a defect in an existing feature label Aug 7, 2023
@RGPosadas RGPosadas changed the title Google Artifact Registry sorting is not defaulting to latest release Google Artifact Registry-based helm chart is not defaulting to latest version Aug 7, 2023
@absoludity
Copy link
Contributor

Thanks for the report @RGPosadas . Note that "4.0.0-cct-1200" is a pre-release version (see point 9 at https://semver.org/#semantic-versioning-specification-semver ) not a latest version, but I do also see you've got a version "3.1.4" which should be the latest version, rather than "3.1.3".

Notes: The log "Requesting chart (latest version)" is printed when a specific version is not requested - the call actually fetches all the versions that it knows about for that repo, then we filter it according to the configurued versions in summary, so what you're seeing in that list is meant to be the latest 3 major versions with the latest 3 minor with the latest 3 patch versions.

It's possible there's an issue in the filtering of that version summary in the frontend dashboard (eg. because there's a pre-release version for both 4.0.0 and 3.1.4, it's incorrectly not considering the non-pre-release 3.1.4 and choosing 3.1.3 - not sure, need to check.

@github-project-automation github-project-automation bot moved this to 🗂 Backlog in Kubeapps Aug 8, 2023
@antgamdia
Copy link
Contributor

antgamdia commented Aug 8, 2023

Besides, I'm noticing there is no appVersion in those charts (example). Perhaps (haven't checked it), the faulty behavior has something to do with it.

Example of the bitnami/apache chart, with appVersion, working properly

image

Edit: I can replicate the issue locally:

Screenshots replicating the issue

image

Even with the API directly:

image

Edit2: I guess this is motivated by the fact that we are relying on the PostgreSQL sorting, which does not take into account the pre-releases... There are some pg extensions for doing so, but maybe we would have to handle this in our codebase.

pkg.LatestVersion = &corev1.PackageAppVersion{
PkgVersion: chart.ChartVersions[0].Version,
AppVersion: chart.ChartVersions[0].AppVersion,
}

@antgamdia antgamdia self-assigned this Aug 8, 2023
@antgamdia antgamdia moved this from 🗂 Backlog to 🏗 In Progress in Kubeapps Aug 8, 2023
@antgamdia antgamdia added this to the Technical debt milestone Aug 8, 2023
@RGPosadas
Copy link
Author

@absoludity Ah yes that's my bad as I was not clear, you are correct - I was expecting either the latest pre-release (4.0.0-cct-1200) or the latest release (3.14) to be the default chart version, instead of 3.13.

@antgamdia Thank you for finding the root cause! Let me know if you need further info 🚀

@antgamdia
Copy link
Contributor

@RGPosadas I have just sent a PR aimed at fixing it: #6588
Thanks for your detailed report of the issue :)

image

@antgamdia antgamdia moved this from 🏗 In Progress to 🔎 In Review in Kubeapps Aug 8, 2023
@absoludity
Copy link
Contributor

absoludity commented Aug 9, 2023

Thanks Antonio. In the screenshot, it's displaying the pre-release version, does that mean that it'll also prompt people to upgrade to the pre-release version by default? I'm not convinced we should be doing that. We should see 3.1.4 IMO, but I'll comment with more context on the PR. EDIT: actually, nm, although it's not ideal, it's what we've always done for Helm here anyway. I'll comment on the PR after a few more thoughts.

All good - I think your solution Antonio is great. Thanks!

@github-project-automation github-project-automation bot moved this from 🔎 In Review to ✅ Done in Kubeapps Aug 9, 2023
antgamdia added a commit that referenced this issue Aug 9, 2023
)

### Description of the change

As described in #6584, we were returning wrong versions in some corner
cases (mainly using pre-releases). It seems we were relying on
`ChartVersions[0]` with the explicit assumption that it would always
contain the latest version. However, this is not the case. Since the DB
does not know about semver (unless we used some
[extensions](/~https://github.com/theory/pg-semver)), the ORDER BY query
might be wrong.

This PR is replacing the occurrences of `ChartVersions[0]` in favor of a
previous semver sorting. The affected operations are:
`GetAvailablePackageDetail`, `GetAvailablePackageSummaries`,
`GetInstalledPackageSummaries` and `GetInstalledPackageDetail`.

### Benefits

The `latestVersion` returned by the API (and therefore used by the UI
-as is-, we don't sort them in client-side) will be the one that has to
be.

### Possible drawbacks

1. In this PR I have just tacked the Helm plugin, not the Flux one.
2. In the code we have relied on this assumption, not 100% of the side
effects, if any.

### Applicable issues

- fixes #6584

### Additional information

Example of a new version being properly detected:


![image](/~https://github.com/vmware-tanzu/kubeapps/assets/11535726/f46dd30b-fc1e-471a-88b1-c434b91ce1d5)

---------

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
@RGPosadas
Copy link
Author

Thanks for the speedy work @antgamdia 🚀
Would you know when this change will be released?
Also, is there an image tag I could use to test the changes?

@antgamdia
Copy link
Contributor

@RGPosadas, anytime; happy to get rid of those bugs :)

We don't have a release date in mind (we are finishing some work on the new oci-catalog component and we'd like to get it done before releasing).
However, you can always get the latest version of any Kubeapps component by switching to the images built by our CI (albeit totally discouraged in production environments). For instance, using kubeapps/dashboard:latest image you'll already get this fix.

@RGPosadas
Copy link
Author

Thanks, will play around with the latest release on our test env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug An issue that reports a defect in an existing feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants