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: capability for both cri manager and container manager #680

Merged
merged 1 commit into from
Feb 2, 2018

Conversation

YaoZengzeng
Copy link
Contributor

Signed-off-by: YaoZengzeng [email protected]

1.Describe what this PR did

With this PR, we could scope the capability of containers.

2.Does this pull request fix one issue?

3.Describe how you did it

4.Describe how to verify it

root@pouch-ubuntu:/home/monster# pouch run busybox:1.26 brctl addbr foobar
brctl: bridge foobar: Operation not permitted
root@pouch-ubuntu:/home/monster# pouch run --cap-add NET_ADMIN busybox:1.26 brctl addbr foobar
root@pouch-ubuntu:/home/monster# 

5.Special notes for reviews

There are some problems with container manager's StartExec method, we couldn't pass the corresponding tests in cri-tools.

I'll fix it ASAP :)

if err := json.Unmarshal([]byte(output), result); err != nil {
c.Errorf("failed to decode inspect output: %v", err)
}
c.Assert(result.HostConfig.CapAdd, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

FAIL: /go/src/github.com/alibaba/pouch/test/cli_create_test.go:170: PouchCreateSuite.TestCreateWithCapability
/go/src/github.com/alibaba/pouch/test/cli_create_test.go:183:
    c.Assert(result.HostConfig.CapAdd, nil)
... Assert(obtained, nil!?, ...):
... Oops.. you've provided a nil checker!

@@ -0,0 +1,24 @@
Copyright 2013 Suryandaru Triandana <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

What kind of this license is it?
It is some kind of different from some usual others.

@codecov-io
Copy link

codecov-io commented Feb 2, 2018

Codecov Report

Merging #680 into master will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #680      +/-   ##
=========================================
- Coverage   10.01%   9.97%   -0.05%     
=========================================
  Files          92      92              
  Lines        5353    5375      +22     
=========================================
  Hits          536     536              
- Misses       4767    4789      +22     
  Partials       50      50
Impacted Files Coverage Δ
daemon/mgr/spec.go 0% <ø> (ø) ⬆️
cli/run.go 0% <0%> (ø) ⬆️
daemon/mgr/cri_utils.go 46.95% <0%> (-0.52%) ⬇️
daemon/mgr/spec_linux.go 0% <0%> (ø) ⬆️
cli/create.go 0% <0%> (ø) ⬆️
cli/container.go 25.6% <0%> (-0.32%) ⬇️

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 4b6bb67...e086274. Read the comment docs.

@YaoZengzeng
Copy link
Contributor Author

@allencloud updated.

@allencloud allencloud added this to the v0.2-milestone milestone Feb 2, 2018
var err error

s := spec.s
if meta.HostConfig.Privileged {
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 add this flag in pouch command line as well?
I found that in cli, there is no privileged flag. @YaoZengzeng

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we could see meta.HostConfig.Privileged in many places associated with security.

I'll use an independent PR to handle it once the security options are complete.

s := spec.s
if meta.HostConfig.Privileged {
caplist = caps.GetAllCapabilities()
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

else if caplist, err = caps.TweakCapabilities(s.Process.Capabilities.Effective, meta.HostConfig.CapAdd, meta.HostConfig.CapDrop); err != nil{
        return err
}

How about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s.Process.Capabilities.Effective is the default capability list. The function here is used to modify it with Capability add-list and drop-list.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I said that maybe we can use else if to reduce an ident. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh! Yes, it is more clear.

s.Process.Capabilities.Effective = caplist
s.Process.Capabilities.Bounding = caplist
s.Process.Capabilities.Permitted = caplist
s.Process.Capabilities.Inheritable = caplist
Copy link
Collaborator

@allencloud allencloud Feb 2, 2018

Choose a reason for hiding this comment

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

I think in this function, we do not need to always use s.Process.Capabilities. We can use caps := s.Process. Capabilities at the very beginning in the function. Then we can use caps.Effective = caplist very simply. Since Capabilities *LinuxCapabilities is a pointer, then we do not worry about another copy or same address thing. And it will make code more clear. WDYT? @YaoZengzeng

We just wish that the data used to communicate among modules or functions should be minimal, so we could encapsulate date transfer very well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree :)

@allencloud
Copy link
Collaborator

LGTM generally. One data transferring issue and a privileged flag. If privileged flag is in your plan but in a follow-up, it is totally OK.

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Feb 2, 2018
@YaoZengzeng
Copy link
Contributor Author

@allencloud updated.

@allencloud
Copy link
Collaborator

re-LGTM

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/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants