Skip to content

Conversation

@rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented Jul 31, 2018

Ⅰ. Describe what this PR did

fix container can't ping outside with nat network.

Ⅱ. Does this pull request fix one issue?

fixes #1920

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

run testcase TestRunWithPing

Ⅴ. Special notes for reviews

Signed-off-by: Rudy Zhang [email protected]

@pouchrobot pouchrobot added kind/bug This is bug report for project size/M labels Jul 31, 2018
@rudyfly rudyfly requested review from Letty5411 and fuweid July 31, 2018 04:30

"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/go-check/check"
Copy link
Contributor

Choose a reason for hiding this comment

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

split into next group

}

// TearDownTest does cleanup work in the end of each test.
func (suite *PouchRunNetworkSuite) TearDownTest(c *check.C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the useless code


// TestRunWithPing is to verify run container with network ping publish website.
func (suite *PouchRunNetworkSuite) TestRunWithPing(c *check.C) {
pc, _, _, _ := runtime.Caller(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

please use the name instead of complicated hacking function

nw, err := nm.controller.NetworkByName(name)
if err != nil {
if err == libnetwork.ErrNoSuchNetwork(name) {
return errors.Wrap(errtypes.ErrNotfound, err.Error())
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 we can keep it the wrap here 😄

Copy link
Collaborator

@allencloud allencloud Jul 31, 2018

Choose a reason for hiding this comment

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

Never ever directly return the ErrNotFound, it will be so ambiguous for user to understand.

No one understands the not found if no context is there. @rudyfly

nw, err := nm.controller.NetworkByName(name)
if err != nil {
if err == libnetwork.ErrNoSuchNetwork(name) {
return errors.Wrap(errtypes.ErrNotfound, err.Error())
Copy link
Collaborator

@allencloud allencloud Jul 31, 2018

Choose a reason for hiding this comment

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

Never ever directly return the ErrNotFound, it will be so ambiguous for user to understand.

No one understands the not found if no context is there. @rudyfly

func (suite *PouchRunNetworkSuite) TearDownTest(c *check.C) {
}

// TestRunWithPing is to verify run container with network ping publish website.
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/publish/public

@allencloud
Copy link
Collaborator

Could you also add an integration test to cover the domain name resolving? @rudyfly

@rudyfly
Copy link
Collaborator Author

rudyfly commented Jul 31, 2018

@fuweid PTAL 😄 @allencloud domain name resolving testcase will be added by next pr.

@allencloud
Copy link
Collaborator

I do not think that this pr fixes the issue #1920, the correct domain name resolving is the right one. @rudyfly

@pouchrobot
Copy link
Collaborator

ping @rudyfly
We found that this PR is 16 commits, which is more than 10 commits, behind master.
Please rebase the branch against master and push it back again. Thanks a lot.

@codecov-io
Copy link

codecov-io commented Jul 31, 2018

Codecov Report

Merging #2025 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2025      +/-   ##
=========================================
- Coverage   63.32%   63.3%   -0.03%     
=========================================
  Files         200     200              
  Lines       15525   15527       +2     
=========================================
- Hits         9831    9829       -2     
- Misses       4454    4456       +2     
- Partials     1240    1242       +2
Flag Coverage Δ
#criv1alpha1test 33.75% <100%> (-0.04%) ⬇️
#criv1alpha2test 34.26% <100%> (ø) ⬆️
#integrationtest 38.44% <100%> (ø) ⬆️
#unittest 21.2% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/network.go 68.79% <100%> (+0.15%) ⬆️
network/mode/bridge/bridge.go 61.4% <100%> (ø) ⬆️
ctrd/watch.go 72.72% <0%> (-3.04%) ⬇️
ctrd/image.go 79.31% <0%> (-1.98%) ⬇️
daemon/logger/jsonfile/utils.go 71.54% <0%> (-1.63%) ⬇️
cri/v1alpha1/cri.go 65.4% <0%> (-0.19%) ⬇️
daemon/mgr/container.go 54% <0%> (+0.15%) ⬆️
cri/v1alpha2/cri.go 66.49% <0%> (+0.17%) ⬆️
apis/server/utils.go 66.66% <0%> (+4.76%) ⬆️

fix container can't ping outside.

Signed-off-by: Rudy Zhang <[email protected]>
@allencloud allencloud changed the title bugfix: fix container can't ping outside. bugfix: fix container can't ping outside and resolve domain names Aug 1, 2018
@allencloud
Copy link
Collaborator

LGTM, tested very well on my local machine.

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Aug 1, 2018
@allencloud allencloud merged commit 5fab7cc into AliyunContainerService:master Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gap/needs-rebase kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] cannot ping www.baidu.com inside container since the dns doesn't work

5 participants