-
Notifications
You must be signed in to change notification settings - Fork 668
Add new server endpoint for installing OCI charts without Helm repository #15863
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
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Comment |
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sowmya-sl The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change: - Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration - Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations - Add unit tests for the new registry client function - Update older tests to use mock registry Client function Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support. Fixes: HELM-611
Add dedicated endpoint and handler for installing Helm charts from OCI registries. This provides a simplified installation flow for OCI charts that doesn't require HelmChartRepository lookup. Changes: - Add InstallOCIChart function in actions for OCI-only installations - Add HandleInstallOCIChart handler with OCI URL validation - Register /api/helm/oci-chart endpoint in server routes - Add tests for both the methods HELM-598
webbnh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that this is still a draft PR, but I have a few comments.
Also, please ensure that all files end with a newline.
pkg/helm/actions/testdata/cleanup.sh
Outdated
| rm -rf ./chartmuseum.tar.gz | ||
| rm -rf ./chartmuseum.tar.gz | ||
| rm -rf ./helm.tar.gz | ||
| # Zot cleanup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the Zot cleanup comprises only a single line, and since we don't have similar comments elsewhere in this file, I would omit this comment.
| set -e | ||
| GOOS=${GOOS:-$(go env GOOS)} | ||
| GOARCH=${GOARCH:-$(go env GOARCH)} | ||
| HELM_VERSION=${HELM_VERSION:-3.19.0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a fixed and silent fallback if HELM_VERSION is undefined is an invitation to trouble in the future (unless we keep the fallback version updated, which is its own kind of trouble).
I strongly recommend exiting with a message and error status if HELM_VERSION is undefined rather than supplying a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly recommend exiting with a message and error status if HELM_VERSION is undefined rather than supplying a default value.
I did not get you? Are you talking about installing helm chart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 7 of the code cited above, we set the value of the local variable $HELM_VERSON to the value of the existing environment variable with the same name, if the environment variable exists; otherwise, we force the value to be a fixed version, which will become increasingly inappropriate as time passes (unless we remember to come back and update this file in the future).
Instead of using the ${ :- } (default value) syntax, we should test that $HELM_VERSION is set, and, if it is not set, then exit the script with an error status.
|
|
||
| mkdir -p "$GOOS-$GOARCH" | ||
|
|
||
| if [ ! -f "$GOOS-$GOARCH/helm" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Bash scripts, [[ is prefered over [.
| #!/bin/bash | ||
|
|
||
| set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you don't turn the -e option back off, I believe you can combine these two lines together:
| #!/bin/bash | |
| set -e | |
| #!/bin/bash -e |
Ditto for the other scripts.
| GOOS=${GOOS:-$(go env GOOS)} | ||
| GOARCH=${GOARCH:-$(go env GOARCH)} | ||
| ZOT_VERSION=${ZOT_VERSION:-v2.1.6} | ||
| ZOT_ARTIFACT_URL="https://github.com/project-zot/zot/releases/download/$ZOT_VERSION/zot-$GOOS-$GOARCH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that this URL is correct? I think the filename should begin with zb instead of zot.
Also, in downloadHelm.sh, the value of HELM_VERSION doesn't include the v (instead, it is added when the URL is constructed); we should probably be consistent in the treatment of ZOT_VERSION.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its zot. Docs say zb is zot benchmark build.
Changed downloadHelm to include v in the HELM_VERSION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed downloadHelm to include v in the HELM_VERSION
I happened to look at pkg/helm/actions/testdata/downloadChartmuseum.sh, and it omits the v from the variable value and adds it when constructing the URL. It would be best if we were consistent across all our files.
Is there a case where we would want a prefix other than v? If not, I suggest omitting it from the value.
| # Push charts to OCI registry using helm push | ||
| echo "Pushing mychart-0.1.0.tgz to oci://$REGISTRY/helm-charts..." | ||
| $HELM push $CHARTS_DIR/mychart-0.1.0.tgz oci://$REGISTRY/helm-charts --ca-file=$CACERT | ||
|
|
||
| echo "Pushing mariadb-7.3.5.tgz to oci://$REGISTRY/helm-charts..." | ||
| $HELM push $CHARTS_DIR/mariadb-7.3.5.tgz oci://$REGISTRY/helm-charts --ca-file=$CACERT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we push two charts? Is there some difference between them which is significant? Or, are we just trying to ensure that the target registry can hold more than one? Or, is it something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I planned to use the other chart for the test with TLS. I will remove now, I can add when we actually do the tests.
| @@ -0,0 +1,34 @@ | |||
| #!/bin/bash | |||
| # Upload Helm charts as OCI artifacts to zot registry (without TLS) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is identical to uploadOciCharts.sh except for the flag on the $HELM command and the port on the registry, right? I recommend combining the scripts and either using a command line argument to select the functionality or just making a single script which runs both sets of tests.
| @@ -0,0 +1,4 @@ | |||
| #!/bin/bash | |||
|
|
|||
| /usr/bin/pkill -15 zot | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend against using a numeric value for the signal and instead suggest using a symbolic value (or just omitting it and using the default signal). (I think -15 is probably -SIGTERM, but I'm not sure, since it can vary between "Unixes"; and, I think that SIGTERM is the default.)
| return GetOCIRegistry(conf, false, false) | ||
| } | ||
|
|
||
| func GetOCIRegistry(conf *action.Configuration, insecure bool, plainHTTP bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"insecure" isn't really a good name: I don't think that the mere fact that we skip the TLS verification necessarily means that the connection is insecure. (At most, I think it means that we cannot be sure who we are connecting to, but the connection itself is, I think, still secure against third-parties.)
I think skipVerify or something similar would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems reasonable.
| releaseName: "valid-chart-path", | ||
| chartPath: "http://localhost:9181/charts/influxdb-3.0.2.tgz", | ||
| chartName: "influxdb", | ||
| chartVersion: "3.0.2", | ||
| }, | ||
| { | ||
| releaseName: "valid-chart-path", | ||
| chartPath: "oci://localhost:5000/helm-charts/mychart:0.1.0", | ||
| chartName: "mychart", | ||
| chartVersion: "0.1.0", | ||
| plainHTTP: true, | ||
| }, | ||
| { | ||
| releaseName: "valid-chart-path", | ||
| chartPath: "oci://localhost:5443/helm-charts/mariadb:7.3.5", | ||
| chartName: "mariadb", | ||
| chartVersion: "7.3.5", | ||
| insecureTLS: true, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It strikes me as odd that all three of these scenarios use the same releaseName value. Prior to your addition, the scenarios each had unique names, which seems appropriate.
The significance of the first scenario is that it uses an HTTP-based chart path, while the new scenarios use OCI-based paths. The difference between the two new paths is that one uses plain HTTP and the other uses TLS without verification. So, there's basis for making the names unique.
However, I have to wonder whether we aren't missing a few cells in the matrix: in terms of variables, we have:
- HTTP vs OCI path schemes
- plain HTTP vs. TLS(?)
- verified TLS vs. unverified TLS, and
- valid vs. invalid paths.
Presumably, for invalid paths, we don't need to test all of the other dimensions. And, presumably, for plain HTTP, we don't need to test TLS verification. But, for a valid path using TLS, presumably we should test both verified and unverified connections with both HTTP and OCI schemes. So, I think that there should be about seven cases:
- (1) invalid path
- valid path
- plain HTTP
- (2) HTTP scheme
- (3) OCI scheme
- TLS
- verified
- (4) HTTP scheme
- (5) OCI scheme
- unverified
- (6) HTTP scheme
- (7) OCI scheme
- verified
- plain HTTP
But, it's possible that not all of those make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test cases make sense. But I am not planning to add TLS test cases till the basic oci support is done end to end. Hope that is fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My recommendation is to add the testing when the CUT (code under test) is added. (Technically, you're supposed to add the tests first, observe that they fail, then update the CUT, and observe that the tests pass...but I'm not sure that I've ever actually done that.... 🙃)
So, if the TLS support isn't going in, then you can omit adding the TLS testing; however, if you're adding latent support for TLS, then you should add the tests which correspond to whatever support you're adding to the CUT.
- Add zot server scripts (zot.sh, zotWithoutTls.sh, zot-stop.sh) and zot configuration files for TLS and non-TLS modes. - Add downloadHelm.sh to download helm v3.19.0 for OCI chart uploads. - Update GetOCIRegistry to support insecure TLS and plain HTTP modes. These modes are necessary as we are self hosting the oci registry for test. - Add TestInstallOCIChart test cases for OCI registries.
8ad9717 to
c8c3aec
Compare
| @@ -0,0 +1,4 @@ | |||
| #!/bin/bash -e | |||
|
|
|||
| /usr/bin/pkill -SIGTERM zot | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that, in #15830, an attempt to use pkill is currently failing.
Add dedicated endpoint and handler for installing Helm charts from OCI
registries. This provides a simplified installation flow for OCI charts
that doesn't require HelmChartRepository lookup.
Changes:
HELM-598