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

enhances the ValidateAppRepository() code to valid OCI Repository type for Helm-Charts and gracefully report errors. #3605

Merged
merged 5 commits into from
Oct 21, 2021

Conversation

satya-dillikar
Copy link
Contributor

Description of the change

This PR enhances the ValidateAppRepository() code to valid OCI Repository type for Helm-Charts and gracefully report errors.

Benefits

User-visible error on UX for non-helm chart OCI Repositories
See screenshot
Screen Shot 2021-10-15 at 4 10 44 PM

Possible drawbacks

Not known

Applicable issues

Additional information

N/A

“satya-dillikar” added 3 commits October 18, 2021 15:24
Signed-off-by: “satya-dillikar” <“satya-dillikar@gmail.com”>
Signed-off-by: “satya-dillikar” <“satya-dillikar@gmail.com”>
Signed-off-by: “satya-dillikar” <“satya-dillikar@gmail.com”>
Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Great start @satya-dillikar ! The code that you've written is working, though there are a few things to check (I've left a bunch of info, given that you're new to go, let me know if it's too much).

There's two other things though stopping this from being landable:

  1. The tests you've added are disabled and can't work currently (since they won't use a fake http client). I've left some notes there about how you should instead modify the existing tests, and
  2. You've not yet deleted the existing code that will no longer be used (for eg. getRequests)

Let me know how you go with the testing and I'll check back.

Thanks!

pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler_test.go Outdated Show resolved Hide resolved
Signed-off-by: “satya-dillikar” <“satya.dillikar@gmail.com”>
@satya-dillikar satya-dillikar changed the title Branch 2962 enhances the ValidateAppRepository() code to valid OCI Repository type for Helm-Charts and gracefully report errors. Oct 19, 2021
Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Thanks @satya-dillikar . A couple of small trivial comments about the code, but regarding the tests, it looks like you've been forced to remove some of the functionality that was being tested as a result of trying to join the two sets of tests into one. I've tried to further detail what I meant in my previous suggestion for the tests. Please have a go, but let me know if it's too hard to follow and I'll instead create a PR showing you what I mean.

pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler_test.go Outdated Show resolved Hide resolved
pkg/kube/kube_handler_test.go Outdated Show resolved Hide resolved
Signed-off-by: “satya-dillikar” <“satya.dillikar@gmail.com”>
Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Thanks Satya. The tests look better now. As I mentioned on slack, I think we still need to do some work in the tests (the first set can be simplified and the second set need to be extended to also test the HelmOCIValidator), but I'm happy to do that in a separate PR as it'll be easier to show what I mean there.

For now, I'm +1 to land this once you confirm that it also works for charts uploaded with Helm 3.6 clients (or in particular, 3.5.4, since that's the version we're using). I suspect we may need to modify it to work since helm 3.7 changed the format slightly, which is probably the cause of the bug that you created.

If it doesn't work for a chart uploaded to an oci repo with a helm client < 3.7, then I suspect what we will want to do is ensure our code works with the pre 3.7 version (which will mean it fails for the 3.7+ version) so that kubeapps can deploy the chart (using its 3.5.4 client). We can then land this PR. After that we'll need to chat with the content team and find out what helm client is currently used to upload bitnami charts to OCI repos (for TAC/VAC) and/or when they plan to update to a helm 3.7 client, as we'll want to update around the same time.

@satya-dillikar
Copy link
Contributor Author

I have packaged two helm charts (podinfo and wordpress) using helm 3.5.4 & pushed to internal harbor (https://harbor-repo.vmware.com/)
I have tested against these charts and confirms thats these PR validations works for helm3.5.4 also.
See details below

✗ which helm354
/usr/local/bin/helm354

✗ helm354 version
version.BuildInfo{Version:"v3.5.4", GitCommit:"1b5edb69df3d3a08df77c9902dc17af864ff05d1", GitTreeState:"clean", GoVersion:"go1.15.11"}

✗ helm354 registry login harbor-repo.vmware.com
Username: sdillikar
Password:
Login succeeded

✗ export HELM_EXPERIMENTAL_OCI=1


✗ helm354 chart save wordpress harbor-repo.vmware.com/vida/wordpress/wordpress:0.20.0
ref:     harbor-repo.vmware.com/vida/wordpress/wordpress:0.20.0
digest:  11ba1b8761f5e33267b9f732861857cfb43727b46e38cde57b8e9e08080d4a01
size:    1.3 KiB
name:    wordpress
version: 0.20.0
0.20.0: saved

✗ helm354 chart list
REF                                                   	NAME     	VERSION	DIGEST 	SIZE   	CREATED
harbor-repo.vmware.com/vida/wordpress/wordpress:0.20.0	wordpress	0.20.0 	11ba1b8	1.3 KiB	10 seconds

✗ helm354 chart push harbor-repo.vmware.com/vida/wordpress/wordpress:0.20.0
The push refers to repository [harbor-repo.vmware.com/vida/wordpress/wordpress]
ref:     harbor-repo.vmware.com/vida/wordpress/wordpress:0.20.0
digest:  11ba1b8761f5e33267b9f732861857cfb43727b46e38cde57b8e9e08080d4a01
size:    1.3 KiB
name:    wordpress
version: 0.20.0
0.20.0: pushed to remote (1 layer, 1.3 KiB total)


 ✗ curl -XGET -H "Authorization: Basic $harborauthz" -H "Accept: application/vnd.oci.image.manifest.v1+json" -s https://harbor-repo.vmware.com/v2/vida/wordpress/wordpress/tags/list\?\n\=1
{"name":"vida/wordpress/wordpress","tags":["0.20.0"]}

 ✗ curl -XGET -H "Authorization: Basic $harborauthz" -H "Accept: application/vnd.oci.image.manifest.v1+json" -s https://harbor-repo.vmware.com/v2/vida/wordpress/wordpress/manifests/0.20.0 | jq .config.mediaType
"application/vnd.cncf.helm.config.v1+json"


✗ helm354 chart save podinfo harbor-repo.vmware.com/vida/podinfo/podinfo:0.20.0
ref:     harbor-repo.vmware.com/vida/podinfo/podinfo:0.20.0
digest:  6013e5506d34ab0410576825062aaebbdd3a48ebf307690d356c1f4c03f849d4
size:    13.2 KiB
name:    podinfo
version: 0.20.0
0.20.0: saved

✗ helm354 chart list
REF                                                   	NAME     	VERSION	DIGEST 	SIZE    	CREATED
harbor-repo.vmware.com/vida/podinfo/podinfo:0.20.0    	podinfo  	0.20.0 	6013e55	13.2 KiB	13 seconds
harbor-repo.vmware.com/vida/wordpress/wordpress:0.20.0	wordpress	0.20.0 	6013e55	1.3 KiB 	9 minutes

✗ helm354 chart push harbor-repo.vmware.com/vida/podinfo/podinfo:0.20.0
The push refers to repository [harbor-repo.vmware.com/vida/podinfo/podinfo]
ref:     harbor-repo.vmware.com/vida/podinfo/podinfo:0.20.0
digest:  6013e5506d34ab0410576825062aaebbdd3a48ebf307690d356c1f4c03f849d4
size:    13.2 KiB
name:    podinfo
version: 0.20.0
0.20.0: pushed to remote (1 layer, 13.2 KiB total)



✗ curl -XGET -H "Authorization: Basic $harborauthz" -H "Accept: application/vnd.oci.image.manifest.v1+json" -s https://harbor-repo.vmware.com/v2/vida/podinfo/podinfo/tags/list\?n\=1
{"name":"vida/podinfo/podinfo","tags":["0.20.0"]}


✗ curl -XGET -H "Authorization: Basic $harborauthz" -H "Accept: application/vnd.oci.image.manifest.v1+json" -s https://harbor-repo.vmware.com/v2/vida/podinfo/podinfo/manifests/0.20.0 | jq .config.mediaType
"application/vnd.cncf.helm.config.v1+json"

harbor-vida
helm3 5 4-screenshot

@absoludity
Copy link
Contributor

Excellent, thanks Satya! Landing!

Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Great work Satya

@absoludity absoludity merged commit 2efc0fe into vmware-tanzu:master Oct 21, 2021
@satya-dillikar satya-dillikar deleted the branch_2962 branch October 28, 2021 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need graceful error handling when adding an OCI repository that has no charts
2 participants