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

Flux oci support 6: implement Update OCI repo and integration tests #5113

Merged
merged 16 commits into from
Jul 25, 2022

Conversation

gfichtenholt
Copy link
Contributor

@gfichtenholt gfichtenholt commented Jul 22, 2022

The goal of this PR was to implement Update() for OCI helm repositories. I expected
flux source-controller to notify my code if the remote OCI repository contents changes,
like it does with a regular HTTP helm repository.

Like most of my PRs, this was test-driven. The plan was:

  1. To write an integration test that is using flux source-controller
    that was failing due to production code I had yet to write
    (i.e. not implemented Update)
  2. Implement Update operaiton
  3. Finish coding integration test

That was the plan. Unfortunately it did not work out due to reasons beyond my
control. For the integration test to be reproducible, I needed to have "my own"
OCI registry the contents of which I can modify (i.e add or delete chart versions)
and I don't have to worry about others making changes to it. In addition to serving this integration test having "my own" registry would be a big stop toward resolving an outstanding dependency to GitHub registry which is not in my ownership, so any chart version hard-coded in the test are subject to change

The PR reflects all my attempts to do so:

  1. I tried to set up a local helm OCI registry over HTTP the way it is advised in
    https://helm.sh/docs/topics/registries/ and have the integration test use that.
    That effort failed due to Flux fails to login to HTTP OCI registry where helm CLI logs in fluxcd/source-controller#805
  2. I tried to set up a local helm OCI registry over HTTPS. That failed due to
    Add support for insecure registries in HelmRepositories of Type oci fluxcd/source-controller#807 and How can I push chart to an insecure OCI registry with helm v3 helm/helm#6324
  3. Since I could not make progress with local registry, I then set up a remote public registry on
    GitHub. I set up access control so others can read, but not modify the repo contents.
    The setup worked but the integration test was ultimately blocked due to flux not supporting
    the use case I had in mind. Requested feature: flux OCI helm repositories notice when tags on remote registry change fluxcd/source-controller#839.
    This discussion is ongoing. I did not want to discard my work so far, because all the scenarios
    should be valid once the dependent issues are resolved

Update 7/25: added an integration test for what is arguably more important scenario that works fine:

  1. remote OCI repo contains only podinfo version 6.1.5
  2. create flux HelmRepository for (1)
  3. create flux HelmRelease for (2) results in podinfo version 6.1.5 deployed
  4. push podinfo version 6.1.6 to (1)
  5. wait for specified repo interval + a bit
  6. now (3) is automatically upgraded to 6.1.6
    i.e. flux server-side is auto-upgrading to latest chart when it is pushed to remote

@netlify
Copy link

netlify bot commented Jul 22, 2022

Deploy Preview for kubeapps-dev canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit c5370b3
🔍 Latest deploy log https://app.netlify.com/sites/kubeapps-dev/deploys/62deb7b7ef7e9f0008058d82

@gfichtenholt gfichtenholt linked an issue Jul 22, 2022 that may be closed by this pull request
Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the integration tests ensuring it works as expected!

@@ -261,7 +261,14 @@ func (r *OCIRegistry) downloadChart(chart *repo.ChartVersion) (*bytes.Buffer, er

// trim the oci scheme prefix if needed
getThis := strings.TrimPrefix(u.String(), fmt.Sprintf("%s://", registry.OCIScheme))
return r.helmGetter.Get(getThis, clientOpts...)
log.Infof("about to call helmGetter.Get(%s)", getThis)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this log should be a debug-level one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these pesky log messages will be gone by end of next week. They're here only while I was actively working on this feature. See my 2nd action item in #5007 (comment). I just haven't got to it yet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great, no problem then. Thanks for the pointer!

@@ -5,88 +5,283 @@

# this is used to build an image that can be used to stand-up a pod that serves static test-data in
# local kind cluster. Used by the integration tests. This script needs to be run once before the running
# the test(s)
# the test(s). This script requires GitHub CLI (gh) to be installed locally. On MacOS you can
# install it via 'brew install gh'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add the link to the releases page:
https://github.com/cli/cli/releases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do. Thank you for the review!

@gfichtenholt gfichtenholt merged commit 59fc732 into vmware-tanzu:main Jul 25, 2022
@gfichtenholt gfichtenholt deleted the flux-oci-support-6 branch July 25, 2022 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Support for OCI registries in Flux plugin
3 participants