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

bugfix: fix exec record user as container config user #1657

Merged
merged 1 commit into from
Jul 11, 2018
Merged

bugfix: fix exec record user as container config user #1657

merged 1 commit into from
Jul 11, 2018

Conversation

Ace-Tang
Copy link
Contributor

@Ace-Tang Ace-Tang commented Jul 9, 2018

pouch exec -u user $container will record user as container
config, fix exec set user.

Signed-off-by: Ace-Tang aceapril@126.com

Ⅰ. Describe what this PR did

without this patch, will get error like:

#pouch run -d --net=none 56a570f9c13c
e02da7e2e50b2a3c6e0242ed8b359860ca8ecd971cc41a84a564e022337bee57

[root@r10f10345.sqa.zmf /root]
#pouch exec -u admin e02da echo 1
1

[root@r10f10345.sqa.zmf /root]
#pouch inspect e02da | grep -i use
            "CpusetCpus": "",
            "CpusetMems": "",
            "User": "admin"

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@pouchrobot pouchrobot added kind/bug This is bug report for project size/S labels Jul 9, 2018
@@ -61,29 +62,26 @@ func (mgr *ContainerManager) StartExec(ctx context.Context, execid string, confi
return err
}

c.Lock()
uid, gid, err = user.Get(c.BaseFS, execConfig.User)
Copy link
Contributor

Choose a reason for hiding this comment

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

%s/=/:=

@@ -61,29 +62,26 @@ func (mgr *ContainerManager) StartExec(ctx context.Context, execid string, confi
return err
}

c.Lock()
uid, gid, err := user.Get(c.BaseFS, execConfig.User)
Copy link
Contributor

Choose a reason for hiding this comment

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

@Ace-Tang can we add some test cases to lock this issue?

@HusterWan
Copy link
Contributor

ci failed, @Ace-Tang PTAC

----------------------------------------------------------------------
FAIL: /go/src/github.com/alibaba/pouch/test/cli_run_user_test.go:34: PouchRunUserSuite.TestRunWithUser
/go/src/github.com/alibaba/pouch/test/cli_run_user_test.go:49:
    c.Fatalf("failed to run a container with user: %s",
        res.Stdout())
... Error: failed to run a container with user: 0

if execConfig.User == "" {
execConfig.User = c.Config.User
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should use container origin user if exec user is null

@fuweid
Copy link
Contributor

fuweid commented Jul 10, 2018

@YaoZengzeng and @starnop please help to check CI. Thanks

@fuweid
Copy link
Contributor

fuweid commented Jul 10, 2018

LGTM

1 similar comment
@YaoZengzeng
Copy link
Contributor

LGTM

@allencloud
Copy link
Collaborator

cri-tools validation fails, see https://travis-ci.org/alibaba/pouch/jobs/402115580

@Ace-Tang
Copy link
Contributor Author

@allencloud , cri test has passed.

@Ace-Tang
Copy link
Contributor Author

Next step, I will combine user.GetAdditionalGids and user.Get function.

@codecov-io
Copy link

codecov-io commented Jul 10, 2018

Codecov Report

Merging #1657 into master will increase coverage by 23.31%.
The diff coverage is 78.57%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1657       +/-   ##
===========================================
+ Coverage   17.86%   41.18%   +23.31%     
===========================================
  Files         229      274       +45     
  Lines       15638    18091     +2453     
===========================================
+ Hits         2794     7450     +4656     
+ Misses      12650     9729     -2921     
- Partials      194      912      +718
Impacted Files Coverage Δ
daemon/config/config.go 19.75% <ø> (+12.34%) ⬆️
main.go 63.15% <100%> (ø)
daemon/mgr/container.go 50.23% <100%> (+50.23%) ⬆️
daemon/daemon.go 56.98% <50%> (ø)
daemon/mgr/container_exec.go 70.52% <80%> (+70.52%) ⬆️
storage/quota/prjquota.go 0% <0%> (ø)
storage/quota/quota.go 12.61% <0%> (ø)
cri/stream/remotecommand/httpstream.go 0% <0%> (ø)
storage/volume/modules/local/local.go 74.24% <0%> (ø)
storage/volume/driver/fake_driver.go 0% <0%> (ø)
... and 128 more

@allencloud
Copy link
Collaborator

Since after the two LGTMs, the code has changed again. I would like to invite @fuweid to take another review. Thanks.

res = command.PouchRun("exec", name, "id", "-u")
res.Assert(c, icmd.Success)
if !strings.Contains(res.Stdout(), "1001") {
c.Fatalf("failed to run a container with user: %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the comment with expected user name. It can show right message if there is any error

1. pouch exec -u user $container will record user as container
config, fix exec set user.
2. fix namespace hardcode in setBaseFS

Signed-off-by: Ace-Tang <aceapril@126.com>
@fuweid
Copy link
Contributor

fuweid commented Jul 11, 2018

LGTM

@fuweid fuweid merged commit d76b476 into AliyunContainerService:master Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants