Skip to content

chore(oci): migrate to ORAS Golang library v2 - #12310

Closed
zregvart wants to merge 2 commits into
helm:mainfrom
zregvart:main
Closed

zregvart wants to merge 2 commits into
helm:mainfrom
zregvart:main

Conversation

@zregvart

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Updates from oras.land/oras-go to oras.land/oras-go/v2. The main user facing change is that the --plain-http parameter is now required even when accessing OCI registries running on localhost.

Fixes #11821

Special notes for your reviewer:

I'm new to this codebase and some tests needed to be adjusted to match the new dependency, please look over the test changes to see if there are any issues with those.

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 16, 2023
@sabre1041 sabre1041 self-assigned this Aug 17, 2023
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved
@zregvart
zregvart force-pushed the main branch 3 times, most recently from 7c04305 to 4255ba2 Compare August 19, 2023 14:26
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved
Comment thread pkg/registry/client.go Resolved

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM but I am not a maintainer.

@joejulian joejulian added the oci Related to Helm OCI feature label Aug 22, 2023
Comment thread pkg/registry/client.go Resolved
@zregvart

Copy link
Copy Markdown
Contributor Author

Thank you @Wwwsylvia for excellent comments and suggestions.
@sabre1041 this has gotten an review and suggestions from two ORAS contributors, can you have a look now?

@sabre1041

Copy link
Copy Markdown
Contributor

Spent some time testing out the integration of the new ORAS v2 library. Below are the results

Test Result Comment
Push Chart with Registry ✅
Pull + show values from Registry ✅
Push Chart with Registry with self signed certificates ✅
Pull + show values from Registry with self signed certificates ✅
Push Chart with Registry with plain http ✅
Pull + show values from Registry with plain http ✅
Login to registry ✅
Logoff from registry ✅
Login to registry with self signed certificates ✅
Logoff from registry with self signed certificates ✅
Login to registry with plain http ❌ Fails. No option exists in Helm to explicitly specify plain http. Existing functionality automatically falls back to plain HTTP and succeeds

The migration looks good, but there does need to be additional work into the one validation failure scenario as described above in addition to the now conflicting go.mod file

@zregvart

Copy link
Copy Markdown
Contributor Author

@sabre1041 how would you like to handle the plain HTTP issue? With a if localhost assume --plain-http? Or should I add a --plain-http flag to helm, the helm push and helm pull already have it.

@sabre1041

Copy link
Copy Markdown
Contributor

@zregvart Personally, I would like to have feature parity with --plain-http in the login subcommand so that it aligns with the rest of capabilities surronding communicating

@zregvart

Copy link
Copy Markdown
Contributor Author

@sabre1041 added support --plain-http to helm login the diff is here.

@sabre1041 sabre1041 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sabre1041

Copy link
Copy Markdown
Contributor

@zregvart This looks good. Can you resolve the conflict and we should be in good shape

@zregvart
zregvart force-pushed the main branch 2 times, most recently from a3cd03e to 1ee13f3 Compare August 29, 2023 14:19
@Wwwsylvia

Copy link
Copy Markdown

Hi @zregvart @sabre1041, FYI, oras-go v2.3.0 is just out, would you like to update the go mod in this PR?

@sabre1041

Copy link
Copy Markdown
Contributor

Hi @zregvart @sabre1041, FYI, oras-go v2.3.0 is just out, would you like to update the go mod in this PR?

@zregvart if you want to update, I can retest again

Comment thread pkg/registry/client.go
}
for _, option := range options {
option(client)
if client.err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't love this. Maybe you can do the validation of options after all the callbacks are processed. This appears to only be used for the deprecated resolver option.

Comment thread pkg/registry/client.go
LoginOption func(*loginOperation)

loginOperation struct {
username string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you'd be better off keeping all these values in loginOperation as a context and doing all the validation after all the callbacks have been processed. This would avoid the error in member and the panic calls.

I don't like this options/operations pattern in general, but that is another matter.

Comment thread pkg/registry/client.go Outdated
credentialsStore credentials.Store
httpClient *http.Client
plainHTTP bool
err error // pass any errors from the ClientOption functions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
err error // pass any errors from the ClientOption functions
resolverSet bool

@zregvart

zregvart commented Sep 9, 2024

Copy link
Copy Markdown
Contributor Author

Thanks @TerryHowe for the review, I think I incorporated the suggestions you made, can you have another look?

@zregvart
zregvart force-pushed the main branch 2 times, most recently from 14dcee5 to ff83b10 Compare September 9, 2024 10:07
@zregvart

zregvart commented Sep 9, 2024

Copy link
Copy Markdown
Contributor Author

Thanks @TerryHowe for the review, I think I incorporated the suggestions you made, can you have another look?

Actually, I can see the tests fail with these changes. I don't have the time or the energy to go troubleshoot this so I'll leave this up to the community.

@dixudx

dixudx commented Oct 8, 2024

Copy link
Copy Markdown

Kindly ping for merging this PR. We NEED this.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it looks like there are some other test failures around credential deletion/logout.

Comment thread pkg/registry/client.go

manifest, err := oras.Copy(ctx, repository, parsedRef.String(), memoryStore, "", oras.CopyOptions{
CopyGraphOptions: oras.CopyGraphOptions{
PreCopy: func(ctx context.Context, desc ocispec.Descriptor) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
PreCopy: func(ctx context.Context, desc ocispec.Descriptor) error {
PreCopy: func(_ context.Context, desc ocispec.Descriptor) error {

@zregvart

Copy link
Copy Markdown
Contributor Author

Found some time today to look at this. I found a race condition around concurrent slice append here, and went back to the idea of keeping the error within the Client struct. Now the code is panic-free. As I write this I see that there is a continuation of this in #13382, thanks for that @TerryHowe, should I close this?

@Happylinzy

Copy link
Copy Markdown

Hi. Any update here?

Updates from `oras.land/oras-go` to `oras.land/oras-go/v2`. The main
user facing change is that the `--plain-http` parameter is now required
even when accessing OCI registries running on `localhost`.

I'm new to this codebase and some tests needed to be adjusted to match
the new dependency, please look over the test changes to see if there
are any issues with those.

Fixes helm#11821

Signed-off-by: Zoran Regvart <[email protected]>
This restores the `ClientOptResolver` function which now panics on
invocation and previous signature of the `LoginOption` function.

Signed-off-by: Zoran Regvart <[email protected]>
@twz123

twz123 commented Jan 16, 2025 •

Copy link
Copy Markdown
Contributor

Now that the main branch is at Helm v4, the time window for the required breaking API change seems open. Is there still some interest in getting this into v4?

Just realizing: #13382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oci Related to Helm OCI feature refactor size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to oras.land/oras-go/v2