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: add capabilities for exec process #2533

Merged
merged 3 commits into from
Dec 6, 2018
Merged

feature: add capabilities for exec process #2533

merged 3 commits into from
Dec 6, 2018

Conversation

Ace-Tang
Copy link
Contributor

@Ace-Tang Ace-Tang commented Dec 5, 2018

add current container capabilities for exec process

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

Ⅰ. Describe what this PR did

add current container capabilities for exec process
if container is created by docker and taken over by pouchd, no config.json can found under current path, runc exec is good even without these capabilities in exec process

Ⅱ. Does this pull request fix one issue?

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

add test for exec priviledged

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Dec 5, 2018

Codecov Report

Merging #2533 into master will increase coverage by 0.1%.
The diff coverage is 78.94%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #2533     +/-   ##
========================================
+ Coverage    69.2%   69.3%   +0.1%     
========================================
  Files         278     278             
  Lines       18494   18513     +19     
========================================
+ Hits        12798   12830     +32     
+ Misses       4243    4230     -13     
  Partials     1453    1453
Flag Coverage Δ
#criv1alpha1test 31.37% <36.84%> (+0.04%) ⬆️
#criv1alpha2test 35.63% <36.84%> (+0.35%) ⬆️
#integrationtest 40.62% <78.94%> (+0.08%) ⬆️
#nodee2etest 32.75% <36.84%> (-0.04%) ⬇️
#unittest 26.88% <0%> (-0.04%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/container_exec.go 79.67% <100%> (+1.6%) ⬆️
daemon/mgr/container_utils.go 85.11% <60%> (-1.59%) ⬇️
daemon/logger/jsonfile/utils.go 71.54% <0%> (-1.63%) ⬇️
daemon/mgr/container.go 59.12% <0%> (-0.22%) ⬇️
cri/v1alpha2/cri_wrapper.go 63.6% <0%> (ø) ⬆️
cri/v1alpha2/cri.go 70.18% <0%> (+0.25%) ⬆️
ctrd/container.go 59.2% <0%> (+1.18%) ⬆️
ctrd/watch.go 84.5% <0%> (+2.81%) ⬆️
daemon/mgr/snapshot.go 94.2% <0%> (+4.34%) ⬆️
pkg/streams/utils.go 91.66% <0%> (+9.52%) ⬆️

Permitted: capList,
Inheritable: capList,
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

just combine else and if to be else if { in this case? @Ace-Tang

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But no else if here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since in the else, there is only one if. So I am wondering if we could make it

else if spec, err := mgr.spec(c); err == nil {
    process.Capabilities = spec.Process.Capabilities
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@@ -125,6 +129,23 @@ func (mgr *ContainerManager) getRuntime(runtime string) (string, error) {
return rPath, nil
}

// spec returns container runtime spec, unmarshal spec from config.json
// TODO: when runtime type can be specified, it need fix
func (mgr *ContainerManager) spec(c *Container) (*specs.Spec, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we rename this function? Actually I am afraid that we could input meaningful details in the function name, for example GetContainerSpec? @Ace-Tang

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, but getContainerSpec, it won't export

@@ -11,6 +11,7 @@ import (
"github.com/alibaba/pouch/pkg/randomid"
"github.com/alibaba/pouch/pkg/streams"
"github.com/alibaba/pouch/pkg/user"
"github.com/docker/docker/daemon/caps"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we replace this package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The package is just there, in vendor , you can change it if you like

add current container capabilities for exec process

Signed-off-by: Ace-Tang <aceapril@126.com>
Signed-off-by: Ace-Tang <aceapril@126.com>
Signed-off-by: Ace-Tang <aceapril@126.com>
@pouchrobot pouchrobot added size/M and removed size/S labels Dec 5, 2018
@@ -54,6 +55,7 @@ func (e *ExecCommand) addFlags() {
flagSet.BoolVarP(&e.Interactive, "interactive", "i", false, "Open container's STDIN")
flagSet.StringVarP(&e.User, "user", "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
flagSet.StringArrayVarP(&e.Envs, "env", "e", []string{}, "Set environment variables")
flagSet.BoolVar(&e.Privileged, "privileged", false, "Give extended privileges to the exec process")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we give extended or all capabilities to the exec process ?

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 give all capabilities, same with run container, the code in daemon show this

@rudyfly
Copy link
Collaborator

rudyfly commented Dec 6, 2018

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Dec 6, 2018
@rudyfly rudyfly merged commit 4b642eb into AliyunContainerService:master Dec 6, 2018
@Ace-Tang Ace-Tang deleted the exec_comp branch December 6, 2018 12:18
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/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants