-
Notifications
You must be signed in to change notification settings - Fork 54
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
✨ follow-ups for containers/image from catalogd and previous PR #1270
✨ follow-ups for containers/image from catalogd and previous PR #1270
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1270 +/- ##
==========================================
- Coverage 76.07% 75.81% -0.26%
==========================================
Files 40 40
Lines 2378 2431 +53
==========================================
+ Hits 1809 1843 +34
- Misses 401 414 +13
- Partials 168 174 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
90cfc74
to
518c8e8
Compare
518c8e8
to
01ffcc0
Compare
@@ -89,7 +85,11 @@ func (i *ContainersImageRegistry) Unpack(ctx context.Context, bundle *BundleSour | |||
if err != nil { | |||
return nil, fmt.Errorf("error creating temporary directory: %w", err) | |||
} | |||
defer os.RemoveAll(layoutDir) | |||
defer func() { | |||
if err := os.RemoveAll(layoutDir); err != nil { |
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.
Should this be deleteRecursive()
?
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 one doesn't have to be because layoutDir
only ever exists while this function is running, and we never set it to be read-only like we do for the unpack dir.
return imgRef, canonicalRef, isCanonical, nil | ||
} | ||
|
||
func resolveCanonicalRef(ctx context.Context, imgRef reference.Named, imageCtx *types.SystemContext) (reference.Canonical, 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.
It's not clear what the bool
return is for. There's no explanation (I assume it's isCanonical
?)
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.
Yeah, its isCanonical
. One way to tell is by looking at the call site in line 178.
But, this one is a bit weird because operator-controller doesn't actually use this variable. Keep moving up the stack and you'll see we discard its value on line 49.
As best I can, I'm trying to keep the function signatures the same between catalogd and operator-controller to facilitate merging later.
@@ -217,7 +241,7 @@ func (i *ContainersImageRegistry) unpackImage(ctx context.Context, unpackPath st | |||
return fmt.Errorf("error creating image source: %w", err) | |||
} | |||
|
|||
if err := os.MkdirAll(unpackPath, 0755); err != nil { | |||
if err := os.MkdirAll(unpackPath, 0700); err != nil { |
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 the restrictive mode?
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.
Also noting setReadOnlyRecursive
... these only set the owner's bits, not group/other.
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 is the same mode as we are setting in applyLayerFilter()
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.
Just trying to be consistent every where. These files are always written and read just by us, so these permissions should be fine. The cache dir is in an emptyDir mount that starts out empty every time a pod starts, so we should never need to be reading files written by another UID.
@@ -45,14 +46,9 @@ func (i *ContainersImageRegistry) Unpack(ctx context.Context, bundle *BundleSour | |||
// Resolve a canonical reference for the image. | |||
// | |||
////////////////////////////////////////////////////// | |||
imgRef, err := reference.ParseNamed(bundle.Image.Ref) | |||
imgRef, canonicalRef, _, err := resolveReferences(ctx, bundle.Image.Ref, i.SourceContext) |
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.
@joelanford I am curious about this change. What triggered this change?
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.
We are moving from a containers/image method to local implementation, hence the question.
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.
Nevermind I saw that it is just a wrapper on top of reference.ParseNamed(ref)
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 was based on a suggestion from catalogd's implementation PR for containers/image. I'm trying to keep them as close to the same as I can.
01ffcc0
to
047a9fc
Compare
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
047a9fc
to
eb59925
Compare
case 0: // regular file | ||
return os.Chmod(path, 0400) | ||
default: | ||
return fmt.Errorf("refusing to change ownership of file %q with type %v", path, typ.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.
Nit: Should we use the type format directive here?
return fmt.Errorf("refusing to change ownership of file %q with type %v", path, typ.String()) | |
return fmt.Errorf("refusing to change ownership of file %q with type %T", path, typ) |
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.
No, I don't think so. This is a file type, not a Go type.
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
I'm ok with the explanations.
f169414
Description
Reviewer Checklist