-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Prevent push cmd failure in 3.18 by handling version tag resolution in ORAS memory store #30894
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
Conversation
- The newReference() function transforms version tags by replacing + with _ for OCI compatibility - But the code was using the original ref (with +) for TagBytes() - Then it tries to find the tagged reference using parsedRef.String() (with _) - This mismatch causes the Resolve method to fail with "not found" - By using parsedRef.String() consistently in both places, the references will match and the lookup will succeed. I extracted the TagBytes function to improve testability. Push() includes several external calls that are hard to mock, so isolating this logic makes testing more manageable. Close: helm#30881 Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
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.
Need to remove the unused parsedRef
@@ -685,19 +685,9 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu | |||
}) | |||
|
|||
ociAnnotations := generateOCIAnnotations(meta, operation.creationTime) |
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 think the parsedRef, err := newReference(ref)
above should be removed
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.
Not sure I get it. The parsedRef
is used here ? 🤔
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.
Line 611. It won't let me comment up there
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.
Is that what you had in mind? f939f61
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.
Ah, yeh, that works
} | ||
|
||
return oras.TagBytes(ctx, memoryStore, ocispec.MediaTypeImageManifest, | ||
manifestData, parsedRef.String()) |
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 is the only actual change here I think, using parsedRef.String()
instead of ref
although the tests are nice.
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.
Yes, exactly. I should have specified it.
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.
Simplified it's this.
- oras.TagBytes(ctx, memoryStore, ocispec.MediaTypeImageManifest, manifestData, ref)
+ oras.TagBytes(ctx, memoryStore, ocispec.MediaTypeImageManifest, manifestData, parsedRef.String())
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.
Yeh, this PR could in theory be just that one line change the way I read it.
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
2c01f66
to
f939f61
Compare
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.
/lgtm
@@ -685,19 +685,9 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu | |||
}) | |||
|
|||
ociAnnotations := generateOCIAnnotations(meta, operation.creationTime) |
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.
Ah, yeh, that works
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.
lgtm
Also manually tested.
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.
LGTM
What this PR does / why we need it:
Fix: #30881
Initial work for
dev-v3
in #30889 (comment) but as requested by @gjenkins8, we should backport after on v3. :)The issue is:
newReference()
function transforms version tags by replacing + with _ for OCI compatibility (as we can see in the output message)TagBytes()
parsedRef.String()
(with _)Resolve
method to fail with "not found"parsedRef.String()
consistently in both places, the references will match and the lookup will succeed.I extracted the
TagBytes
function to improve testability.Push()
includes several external calls that are hard to mock, so isolating this logic makes testing more manageable.The patch could be summarized as:
The initial regression is something that was missed in 5a7046b#diff-acbc1e889c3e91003a88f18e21c3073b64937801b20f663fcf2601540b9e3cdaR709
Before :
After :
Special notes for your reviewer:
If applicable:
docs needed
label should be applied if so)