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

bugfix: fix can't set macaddress for endpoint #2222

Merged
merged 1 commit into from
Sep 10, 2018

Conversation

rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented Sep 10, 2018

Ⅰ. Describe what this PR did

When user set the mac address in container's config:
container.Config.MacAddress, now it will not take effect.

The method is setting the mac address into the endpoint's options, it
will set into network device by libnetwork or it's remote plugins.

Ⅱ. Does this pull request fix one issue?

NONE

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

Add testcase: TestCreateWithMacAddress to check the mac address is set
into container's device or not.

Ⅳ. Describe how to verify it

Using testcase TestCreateWithMacAddress to verify it

Ⅴ. Special notes for reviews

NONE

Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com

When user set the mac address in container's config:
`container.Config.MacAddress`, now it will not take effect.

The method is setting the mac address into the endpoint's options, it
will set into network device by libnetwork or it's remote plugins.

Add testcase: `TestCreateWithMacAddress` to check the mac address is set
into container's device or not.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
@pouchrobot pouchrobot added kind/bug This is bug report for project size/L labels Sep 10, 2018
if err != nil {
return nil, err
}
genericOption, _ = utils.MergeMap(genericOption, options.Generic{netlabel.MacAddress: mac})
Copy link
Contributor

Choose a reason for hiding this comment

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

we already have Merge funtion in utils.go, can we use it ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can't to merge the map as I want, I don't know and I don't want to knon what's wrong with it. 🐶

@codecov-io
Copy link

Codecov Report

Merging #2222 into master will increase coverage by 0.06%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2222      +/-   ##
=========================================
+ Coverage   64.83%   64.9%   +0.06%     
=========================================
  Files         208     208              
  Lines       16728   16744      +16     
=========================================
+ Hits        10846   10868      +22     
+ Misses       4526    4525       -1     
+ Partials     1356    1351       -5
Flag Coverage Δ
#criv1alpha1test 32.94% <5.55%> (+0.09%) ⬆️
#criv1alpha2test 33.43% <5.55%> (-0.06%) ⬇️
#integrationtest 39.95% <50%> (-0.01%) ⬇️
#unittest 23.87% <55.55%> (+0.04%) ⬆️
Impacted Files Coverage Δ
pkg/utils/utils.go 85.16% <100%> (+0.86%) ⬆️
daemon/mgr/network.go 69.13% <62.5%> (-0.04%) ⬇️
cri/stream/portforward/httpstream.go 69.16% <0%> (-6.67%) ⬇️
apis/server/utils.go 61.9% <0%> (-4.77%) ⬇️
cri/stream/runtime.go 68.23% <0%> (-2.36%) ⬇️
cri/v1alpha1/cri.go 62.22% <0%> (+0.33%) ⬆️
ctrd/image.go 77.19% <0%> (+0.43%) ⬆️
daemon/mgr/container.go 56.76% <0%> (+0.61%) ⬆️
apis/server/container_bridge.go 79.25% <0%> (+0.74%) ⬆️
ctrd/container.go 53.82% <0%> (+0.95%) ⬆️
... and 2 more

@HusterWan
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Sep 10, 2018
@HusterWan HusterWan merged commit 1a80143 into AliyunContainerService:master Sep 10, 2018
// MergeMap merges the m2 into m1, if it has the same keys, m2 will overwrite m1.
func MergeMap(m1 map[string]interface{}, m2 map[string]interface{}) (map[string]interface{}, error) {
if m1 == nil && m2 == nil {
return nil, fmt.Errorf("all of maps are nil")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does it return an error? I think it is quite normal to merge two nil map.

I think it is incorrect to return err. Instead, the upper caller could judge whether the returned value is nil to return error or something.

MergeMap is a general function and fundamental, it should not add some business logic in the implementation. For me, judging both of them nil is business logic.


c.Assert(found, check.Equals, true)

DelContainerForceMultyTime(c, cname)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use defer to delete container to avoid legacy container for other tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants