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

refactor: Extract cni manager as the public part #1719

Merged
merged 1 commit into from
Jul 30, 2018

Conversation

starnop
Copy link
Contributor

@starnop starnop commented Jul 12, 2018

Signed-off-by: Starnop [email protected]

Ⅰ. Describe what this PR did

For now,The organization of the code about CNI Manager is unreasonable,we should reorganize the file structure: extract cni manager as the public part.

Ⅱ. Does this pull request fix one issue?

fixes part of #1524

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Jul 12, 2018

Codecov Report

Merging #1719 into master will decrease coverage by 0.12%.
The diff coverage is 70.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1719      +/-   ##
==========================================
- Coverage   58.68%   58.56%   -0.13%     
==========================================
  Files         200      200              
  Lines       15565    15514      -51     
==========================================
- Hits         9135     9085      -50     
- Misses       5143     5145       +2     
+ Partials     1287     1284       -3
Flag Coverage Δ
#criv1alpha1test 33.39% <35.13%> (+0.18%) ⬆️
#criv1alpha2test 33.87% <35.13%> (+0.07%) ⬆️
#integrationtest 37.63% <0%> (-0.27%) ⬇️
#unittest 13.68% <0%> (+0.24%) ⬆️
Impacted Files Coverage Δ
cri/ocicni/cni_manager.go 51.21% <0%> (ø)
cri/ocicni/noop_cni_manager.go 0% <0%> (ø)
cri/v1alpha1/cri.go 65.04% <100%> (-0.19%) ⬇️
cri/v1alpha2/cri_utils.go 80.15% <100%> (+0.38%) ⬆️
cri/v1alpha1/cri_utils.go 74.28% <100%> (+0.56%) ⬆️
cri/v1alpha2/cri.go 66.13% <100%> (ø) ⬆️
daemon/containerio/hijack_conn.go 77.14% <0%> (-11.43%) ⬇️
daemon/containerio/container_io.go 69.61% <0%> (-4.98%) ⬇️
pkg/meta/store.go 52.38% <0%> (-4.77%) ⬇️
apis/server/utils.go 61.9% <0%> (-4.77%) ⬇️
... and 7 more

// Teardown network if an error returned.
err := c.plugin.TearDownPod(*podNetwork)
if err != nil {
logrus.Errorf("failed to detroy network for sandbox %q: %v", podNetwork.ID, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/detroy/destroy

@@ -0,0 +1,24 @@
package ocicni
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think defining an interface should use a filename of types.go.
Instead, maybe cnimanager.go is a better one. WDYT?

Copy link
Contributor Author

@starnop starnop Jul 13, 2018

Choose a reason for hiding this comment

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

cnimanager.go doesn't make sense, there is a file named cni_manager.go. So maybe apis.go or something else? WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@YaoZengzeng
Any advice?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think types.go is fine, we could expand it if we need more types 😄

@allencloud
Copy link
Collaborator

Sounds good to me, but some nits still need update. @starnop


import (
"fmt"
"github.com/alibaba/pouch/cri/config"
Copy link
Contributor

Choose a reason for hiding this comment

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

please move it into the group.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

func (c *CniManager) Status() error {
return c.plugin.Status()
}

// toCNIPortMappings converts CRI port mappings to CNI.
func toCNIPortMappings(criPortMappings []*runtime.PortMapping) []ocicni.PortMapping {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move this function to cri_utils.go and rm this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, maybe we'll consider creating separate files in the future when we have more utility functions.

func (c *CniManager) Status() error {
return c.plugin.Status()
}

// toCNIPortMappings converts CRI port mappings to CNI.
func toCNIPortMappings(criPortMappings []*runtime.PortMapping) []ocicni.PortMapping {
Copy link
Contributor

Choose a reason for hiding this comment

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

The same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@allencloud
Copy link
Collaborator

PTAL @YaoZengzeng

@YaoZengzeng
Copy link
Contributor

LGTM

@allencloud allencloud merged commit ba29cd3 into AliyunContainerService:master Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants