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 failed to run a container with specifying a non-exist workdir #2127

Merged

Conversation

HusterWan
Copy link
Contributor

Signed-off-by: Michael Wan zirenwan@gmail.com

Ⅰ. Describe what this PR did

Fix a problem that failed to run a container when specifying a not-exist working directory

root@osboxes:pouch (zr/fix-workdir-notfound *) -> pouch run -d -t --name=test -e "GOSU_VERSION=2.0" -e "test=foo" --net=bridge -v /data  -w /tmp/ziren registry.hub.docker.com/library/mysql:5.7 top
Error: failed to run container test: {"message":"failed to create container(5e1065ae1b4a3b22914203dd64b1a2fbd305c90b8c6b567366b23b312f0a86dd) on containerd: failed to create task for container(5e1065ae1b4a3b22914203dd64b1a2fbd305c90b8c6b567366b23b312f0a86dd): OCI runtime create failed: container_linux.go:265: starting container process caused \"chdir to cwd (\\\"/tmp/ziren\\\") set in config.json failed: no such file or directory\": unknown"}

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

add TestRunWithExistWorkingDir TestRunWithNotExistWorkingDir

Ⅳ. Describe how to verify it

Creating a container specifying a workdir not exist should success

 pouch run -d -t --name=test  -v /data  -w /tmp/test/notexist centos top

Ⅴ. Special notes for reviews

@pouchrobot pouchrobot added areas/test kind/bug This is bug report for project size/XL labels Aug 20, 2018
@HusterWan HusterWan requested review from rudyfly and fuweid August 20, 2018 11:27
@HusterWan HusterWan force-pushed the zr/fix-workdir-notfound branch from 918b54e to 1349d95 Compare August 20, 2018 11:32
@codecov-io
Copy link

codecov-io commented Aug 20, 2018

Codecov Report

Merging #2127 into master will increase coverage by 2.07%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2127      +/-   ##
==========================================
+ Coverage   59.63%   61.71%   +2.07%     
==========================================
  Files         208      208              
  Lines       16482    16498      +16     
==========================================
+ Hits         9829    10181     +352     
+ Misses       5453     5055     -398     
- Partials     1200     1262      +62
Flag Coverage Δ
#criv1alpha1test 33% <41.17%> (-0.14%) ⬇️
#criv1alpha2test 31.65% <23.07%> (?)
#integrationtest 39.56% <88.23%> (+0.05%) ⬆️
#unittest 23.88% <0%> (-0.03%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/container_exec.go 68.26% <100%> (+0.94%) ⬆️
daemon/mgr/container_storage.go 48.58% <84.61%> (+1.13%) ⬆️
ctrd/watch.go 72.72% <0%> (-7.58%) ⬇️
daemon/mgr/container.go 55.46% <0%> (-0.41%) ⬇️
cri/v1alpha1/cri.go 63.44% <0%> (-0.35%) ⬇️
daemon/logger/jsonfile/utils.go 73.17% <0%> (+1.62%) ⬆️
apis/server/utils.go 66.66% <0%> (+4.76%) ⬆️
cri/stream/runtime.go 68.23% <0%> (+5.88%) ⬆️
cri/criservice.go 64.7% <0%> (+24.99%) ⬆️
cri/v1alpha2/cri_utils.go 82.33% <0%> (+27.18%) ⬆️
... and 4 more


c.Config.WorkingDir = filepath.Clean(c.Config.WorkingDir)

path := filepath.Join(c.MountFS, c.Config.WorkingDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

does runc change user mode of the working dir?

Copy link
Contributor

Choose a reason for hiding this comment

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

@fuweid , both pouch and runc do not change owner about workdir, since we do not have id map in pouch, create it as a root user with filemode 0755 is enough.

@Ace-Tang
Copy link
Contributor

@HusterWan , please make sure the following case is good, also a test is need

#pouch run --net=none -it --rm  -w /home/tmp reg.docker.alibaba-inc.com/ali/os:7u2 bash

[root@6b4914ad9e38 /home/tmp]

container 6b4914ad9e38 has workdir /home/tmp, when exec into it, workdir should be same, like

#pouch exec -it 6b4914ad9e38 bash

[root@6b4914ad9e38 /home/tmp]

@HusterWan
Copy link
Contributor Author

@Ace-Tang Good advices

test below is ok :

pouch run --net=none -it --rm  -w /home/tmp reg.docker.alibaba-inc.com/ali/os:7u2 bash

[root@6b4914ad9e38 /home/tmp]

but now, we not support set working directory when execute exec, i will add soon

…ing directory

Signed-off-by: Michael Wan <zirenwan@gmail.com>
@HusterWan HusterWan force-pushed the zr/fix-workdir-notfound branch from 9cfd5ef to 52a7620 Compare August 21, 2018 11:06
@pouchrobot pouchrobot added size/XL and removed size/L labels Aug 21, 2018
@HusterWan
Copy link
Contributor Author

@Ace-Tang Updated, all test cases added

cc @fuweid @allencloud

@Ace-Tang
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Aug 21, 2018
@Ace-Tang Ace-Tang merged commit 105f412 into AliyunContainerService:master Aug 21, 2018
@HusterWan HusterWan deleted the zr/fix-workdir-notfound branch August 21, 2018 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/test kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants