-
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
refactor: refact the setup spec mount #2653
refactor: refact the setup spec mount #2653
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2653 +/- ##
=========================================
+ Coverage 69.38% 69.6% +0.22%
=========================================
Files 280 280
Lines 18845 18857 +12
=========================================
+ Hits 13075 13125 +50
+ Misses 4293 4266 -27
+ Partials 1477 1466 -11
|
daemon/mgr/spec_mount.go
Outdated
@@ -42,7 +42,12 @@ func clearReadonly(m *specs.Mount) { | |||
|
|||
// setupMounts create mount spec. | |||
func setupMounts(ctx context.Context, c *Container, s *specs.Spec) error { | |||
if c.HostConfig == nil { | |||
return 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.
Return error
here
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.
delete this line
daemon/mgr/spec_mount.go
Outdated
@@ -121,10 +116,19 @@ func setupMounts(ctx context.Context, c *Container, s *specs.Spec) error { | |||
mounts = append(mounts, generateNetworkMounts(c)...) | |||
} | |||
|
|||
s.Mounts = sortMounts(mounts) | |||
// modify share memory size, and change rw mode for privileged mode. | |||
for i := range s.Mounts { |
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/s.Mounts/mounts/, use combined mount
c09ff0b
to
58b7248
Compare
58b7248
to
0495722
Compare
0495722
to
71c32e8
Compare
refact the setup spec mount, make it a logical structure as below: 1. override the default spec mounts by container's config; 2. setup container's mounts into spec mounts; 3. setup or modify extra configs into spec mounts; 4. sort all spec mounts. Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
71c32e8
to
9f904bd
Compare
// setupMounts create mount spec. | ||
func setupMounts(ctx context.Context, c *Container, s *specs.Spec) error { | ||
var ( | ||
mounts []specs.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.
no need to define this parameter, WDYT?
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 it need.
func setupMounts(ctx context.Context, c *Container, s *specs.Spec) error { | ||
var mounts []specs.Mount | ||
// Override the default mounts which are duplicate with user defined ones. | ||
func overrideDefaultMount(mounts []specs.Mount, c *Container, s *specs.Spec) ([]specs.Mount, error) { |
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.
Maybe we can add some test cases for the new function.
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.
It isn't complicated logic, I think it no need to add unit test.
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.
Should add, but can be in another pr
LGTM |
Ⅰ. Describe what this PR did
refect the setup spec mount, make it a logical structure as below:
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
NO
Ⅳ. Describe how to verify it
NA
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com