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

Support getting uid/gid from rootfs path #2009

Merged
merged 2 commits into from Jan 17, 2018

Conversation

crosbymichael
Copy link
Member

@crosbymichael crosbymichael commented Jan 16, 2018

This allows the spec opts for getting the uid/gid from /etc/passwd from either a container with a snapshot or with a hardcoded rootfs path.

Closes #1995

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
return errors.Errorf("rootfs snapshot not created for container")
if c.Snapshotter == "" && c.SnapshotKey == "" {
if s.Root.Path == "" {
if c.Snapshotter == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if (and the following one) seem redundant because the previous line (260) already checked this condition. I think this could error immediately with "no shapshotter and rootfs set for container".

Or is 260 supposed to be || ? With && it means that if one of them is the empty string the "else" block below could fail in an unexpected way.

Copy link
Member Author

Choose a reason for hiding this comment

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

These errors are only returned when all 3 are empty. And there are separate error messages for each missing field. I think i retained that same logic with the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

The second missing field block (line 265) would never be hit, it's dead code, and there are unhandled error cases:

c.Snapshotter c.SnapshotKey s.Root.Path result
"" "" "" errors.Errorf("no snapshotter set for container")
"overlay" "" n/a (goes to line 282 and may error because snapshotkey is "")
"" "foo" n/a (goes to line 282 and may error because Snapshotter is "")
"overlay" "foo" n/a (goes to line 282 and shouldn't error)
"" "" /something (goes to line 269 and shouldn't error)

right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you are reading it wrong on your second line in the table. It won't go to 282, it goes to 265 and errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

same for the third line

return errors.Errorf("rootfs snapshot not created for container")
if c.Snapshotter == "" && c.SnapshotKey == "" {
if s.Root.Path == "" {
if c.Snapshotter == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@crosbymichael crosbymichael force-pushed the user-path branch 3 times, most recently from 4a915f8 to aa6804a Compare January 16, 2018 19:15
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM!

}

func isRootfsAbs(root string) bool {
if root != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is this required? filepath.IsAbs("") seems to return false on linux, but maybe it's not guaranteed to be on all platforms?

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
@codecov-io
Copy link

Codecov Report

Merging #2009 into master will decrease coverage by 0.09%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #2009     +/-   ##
=========================================
- Coverage   45.57%   45.48%   -0.1%     
=========================================
  Files          94       94             
  Lines        9296     9315     +19     
=========================================
  Hits         4237     4237             
- Misses       4351     4370     +19     
  Partials      708      708
Flag Coverage Δ
#linux 50.06% <0%> (-0.13%) ⬇️
#windows 40.43% <ø> (ø) ⬆️
Impacted Files Coverage Δ
oci/spec_opts_unix.go 5.85% <0%> (-0.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbb5b2f...1f5ce14. Read the comment docs.

Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@estesp estesp merged commit aaf930e into containerd:master Jan 17, 2018
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.

None yet

5 participants