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

feature: user configuration for cri manager #722

Merged
merged 1 commit into from
Feb 13, 2018

Conversation

YaoZengzeng
Copy link
Contributor

@YaoZengzeng YaoZengzeng commented Feb 9, 2018

Signed-off-by: YaoZengzeng [email protected]

Ⅰ. Describe what this PR did

Actually the user option is so complicated in docker, it could be in format as follows:
"" | "user" | "uid" | "user:group" | "uid:gid" | "user:gid" | "uid:group"

Hmmm... It is hard to implement all of them in a short time.

With this PR, you could only specify user option with "uid", but in most cases, it is enough 😄

Ⅱ. Does this pull request fix one issue?

fixes part of #635

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Feb 9, 2018

Codecov Report

Merging #722 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #722      +/-   ##
==========================================
- Coverage   12.26%   12.24%   -0.02%     
==========================================
  Files          97       97              
  Lines        5856     5865       +9     
==========================================
  Hits          718      718              
- Misses       5087     5096       +9     
  Partials       51       51
Impacted Files Coverage Δ
daemon/mgr/cri_utils.go 39.32% <0%> (-0.99%) ⬇️
cli/create.go 0% <0%> (ø) ⬆️
daemon/mgr/spec_process.go 0% <0%> (ø) ⬆️
cli/run.go 0% <0%> (ø) ⬆️
daemon/mgr/container.go 3.18% <0%> (-0.02%) ⬇️
cli/container.go 50.26% <0%> (-0.27%) ⬇️

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 fca436a...03d0a3b. Read the comment docs.

@@ -59,27 +58,20 @@ func setupProcessTTY(ctx context.Context, c *ContainerMeta, spec *SpecWrapper) e
}

func setupProcessUser(ctx context.Context, c *ContainerMeta, spec *SpecWrapper) (err error) {
// The user option is complicated, now we only handle case "uid".
// TODO: handle other cases like "user", "uid:gid", etc.
if c.Config.User != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you use

if c.Config.user == "" {
    return nil
}

fields := strings.Split(c.Config.User, ":")
......

to reduce ident?

fields := strings.SplitN(c.Config.User, ":", 2)
var u, g string
fields := strings.Split(c.Config.User, ":")
var u string
u = fields[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

u still has possibility of being empty string, just make c.Config.User to be :asdfghj. right?

user.UID = uint32(uid)
} else {
user.Username = u
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allencloud it's OK if the user option ":group", we will get an empty spec.User{} and will not cause any bad influence.

@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Feb 13, 2018
@allencloud allencloud merged commit 6573453 into AliyunContainerService:master Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants