-
Notifications
You must be signed in to change notification settings - Fork 950
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
feature: capability for both cri manager and container manager #680
Conversation
test/cli_create_test.go
Outdated
if err := json.Unmarshal([]byte(output), result); err != nil { | ||
c.Errorf("failed to decode inspect output: %v", err) | ||
} | ||
c.Assert(result.HostConfig.CapAdd, nil) |
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.
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]> |
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.
What kind of this license is it?
It is some kind of different from some usual others.
792c37c
to
8d6e754
Compare
8d6e754
to
ce11709
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@allencloud updated. |
daemon/mgr/spec_linux.go
Outdated
var err error | ||
|
||
s := spec.s | ||
if meta.HostConfig.Privileged { |
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.
Could you add this flag in pouch command line as well?
I found that in cli, there is no privileged flag. @YaoZengzeng
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.
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.
daemon/mgr/spec_linux.go
Outdated
s := spec.s | ||
if meta.HostConfig.Privileged { | ||
caplist = caps.GetAllCapabilities() | ||
} else { |
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.
else if caplist, err = caps.TweakCapabilities(s.Process.Capabilities.Effective, meta.HostConfig.CapAdd, meta.HostConfig.CapDrop); err != nil{
return err
}
How about this?
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.
s.Process.Capabilities.Effective is the default capability list. The function here is used to modify it with Capability add-list and drop-list.
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 said that maybe we can use else if
to reduce an ident. 😄
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.
Oh! Yes, it is more clear.
daemon/mgr/spec_linux.go
Outdated
s.Process.Capabilities.Effective = caplist | ||
s.Process.Capabilities.Bounding = caplist | ||
s.Process.Capabilities.Permitted = caplist | ||
s.Process.Capabilities.Inheritable = caplist |
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 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.
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.
Agree :)
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. |
Signed-off-by: YaoZengzeng <[email protected]>
ce11709
to
e086274
Compare
@allencloud updated. |
re-LGTM |
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
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 :)