Skip to content

fix running a container with config.User#1994

Merged
crosbymichael merged 4 commits intocontainerd:masterfrom
AkihiroSuda:fix-user
Jan 12, 2018
Merged

fix running a container with config.User#1994
crosbymichael merged 4 commits intocontainerd:masterfrom
AkihiroSuda:fix-user

Conversation

@AkihiroSuda
Copy link
Copy Markdown
Member

Previously, it had been failing due to ctr: rootfs snapshot not created for container

Also, nil err from WithUsername were accidentally ignored.

Comment thread oci/spec_opts_unix.go Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

opened TODO issue: #1995

@AkihiroSuda
Copy link
Copy Markdown
Member Author

@stevvooe Can we back port this to 1.0.1?

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 11, 2018

Codecov Report

Merging #1994 into master will increase coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1994      +/-   ##
=========================================
+ Coverage   45.58%   45.6%   +0.01%     
=========================================
  Files          94      94              
  Lines        9285    9282       -3     
=========================================
  Hits         4233    4233              
+ Misses       4344    4341       -3     
  Partials      708     708
Flag Coverage Δ
#linux 50.21% <0%> (+0.02%) ⬆️
#windows 40.47% <ø> (ø) ⬆️
Impacted Files Coverage Δ
oci/spec_opts_unix.go 6.4% <0%> (+0.09%) ⬆️

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 90553ef...1645d84. Read the comment docs.

Copy link
Copy Markdown
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.

The fix for the error return seems right; the ordering "fix" inside ctr run I have a question about generally with respect to our client API.

Comment thread cmd/ctr/commands/run/run_unix.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this fixes ctr, but seems like this leaves a hole in the overall client API that currently doesn't say anything about option "precedence." Are there other cases where behavior is different based on ordering?

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.

@crosbymichael did you ever implement your idea to take care of this somewhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thats the problem with ctr, the ordering is what we made it. As far as other clients go, the supported usecase of the API, the ordering/precedence is what they define.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess my point is slightly different; if I create a new client for containerd using the published Go API, there is nothing that tells me the way I order my 'opts' when using containerd's API for NewContainer could affect outcome (e.g. error versus working container). Do we need some note and/or, if we know the "valid" orderings, should we/can we fix it on the API implementation side.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't know how we can fix that. Since opts can be created by the user the best I know to do is give them the information they need to setup things correctly.

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 shouldn't be too difficult. The problem is the dependency is not explicit from the function signature. So we can fix that by changing it to:

func WithUserID(uid uint32, snapshotter snapshots.Snapshotter, rootfs string)

Of course this is more work to use, but it does make the dependencies obvious.

A change like this would also potentially allow us to remove client Client from the args in SpecOpt, which I think is a good thing. It's rarely used (these 2 functions are the only place it's referenced) and it introduces problems like this (where dependencies aren't clear).

Any SpecOpt that actually needs client (or something from client), can accept that as an arg to the function which returns the SpecOpt (like the WithUserID example above).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dnephin good idea.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

+1, but it should be probably separate PR for 1.1

Comment thread oci/spec_opts_unix.go Outdated
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'm not sure about this change, I think the old code may have been wrong as well.

If WithUsername is successful, shouldn't it continue to run the code after the switch (setting cwd) ?

Alternatively may this can be refactored so that the CWD code is above this switch, which would let us keep this early return, and also let us return WithUserID(...) below, instead of checking err there as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed, thanks

Comment thread oci/spec_opts_unix.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should use SplitN with an argument of 2, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure. I think the current code is ok.

@stevvooe
Copy link
Copy Markdown
Member

@AkihiroSuda This change needs a few tweaks. Since ctr isn't really supported for any kind of production use cases, we can push this to 1.0.2.

@stevvooe stevvooe added this to the 1.0.2 milestone Jan 11, 2018
Signed-off-by: Akihiro Suda <[email protected]>
Signed-off-by: Akihiro Suda <[email protected]>
Signed-off-by: Akihiro Suda <[email protected]>
@AkihiroSuda
Copy link
Copy Markdown
Member Author

@stevvooe

The WithImageConfig change is not specific to ctr.
Any chance to cherry pick this in v1.0.1 ?

Copy link
Copy Markdown
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

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@AkihiroSuda
Copy link
Copy Markdown
Member Author

opened cherry pick PR #2005

@stevvooe stevvooe modified the milestones: 1.0.2, 1.0.1 Jan 16, 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.

7 participants