-
Notifications
You must be signed in to change notification settings - Fork 944
fix: check user/group in container start #1716
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1716 +/- ##
==========================================
+ Coverage 41.62% 41.78% +0.15%
==========================================
Files 278 278
Lines 18225 18244 +19
==========================================
+ Hits 7586 7623 +37
+ Misses 9709 9695 -14
+ Partials 930 926 -4
|
|
|
||
| // GetSpecificBasePath accepts a given path, look for whether the path is exist | ||
| // within container, if has, returns container base path like BaseFS, if not, return empty string | ||
| func (c *Container) GetSpecificBasePath(path string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel weird ! can we judge whether the baseFS is mounted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is used to get specified file from container, BaseFs is not created when container start, so we can only try image path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still have another question: can we ensure passwd file exists in UpperDir?
Or can we mount the mergedDir when we found it not mounted, then we can ensure the passwd file exists in MergedDir.
it's just my advice, you can think about it again, thanks a lot @Ace-Tang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we run a container, merged dir is not created yet until pouch pass create options to containerd, then containerd created it and mount. Add this function cause we can only find file in image when container in start process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think this pr can fix if merged dir is un-mounted by error.
daemon/mgr/container_types.go
Outdated
| "github.com/alibaba/pouch/cri/stream/remotecommand" | ||
| "github.com/alibaba/pouch/pkg/meta" | ||
| "github.com/alibaba/pouch/pkg/utils" | ||
| "github.com/containerd/containerd/mount" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please put this line to third-party package
| return c.BaseFS | ||
| } | ||
|
|
||
| // then try lower and upper directory, since overlay filesystem support only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a good solution to fix mergeDir not mounted 👋
|
@HusterWan ,Updated. Beside, I have test a occasion that umount container rootfs to see if exec will successful. |
user parameter passed by pouch run --user is not validate in container start process, since we just try to find file in BaseFS, but BaseFS is created in containerd, so we pass the validate. Fix this by find file in image container use. Add function Get which has GetUser and GetAdditionalGids function as a interface in pkg/user package. Signed-off-by: Ace-Tang <[email protected]>
|
lgtm |
user parameter passed by pouch run --user is not validate in container
start process, since we just try to find file in BaseFS, but BaseFS is
created in containerd, so we pass the validate. Fix this by find file in
image container use.
Add function Get which has GetUser and GetAdditionalGids function as a
interface in pkg/user package.
Signed-off-by: Ace-Tang [email protected]
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews