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

Fix configure network fails after a successful DHCP configuration #188

Merged
merged 3 commits into from
Jul 18, 2017

Conversation

ailisp
Copy link
Member

@ailisp ailisp commented Jul 14, 2017

ISSUE: After a successful DHCP configuration, if you configure network using static ipv6 it will fails. That fails is actually ifdown returns 1 indicate previous setting to network (DHCP) one is not successfully shutdown. However, actually it does if you run ifconfig at this time. This is why the network configuration becomes empty in appliance console status: ifdown fails so NetworkInterfaceRH.save returns false immediately without start up eth0 using old configuration or new configuration. After ifdown returns 1 if we run another ifdown it will return 0 and subsequent ifup new configuration works.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1464999

\cc @yrudman @carbonin

@miq-bot add-label wip,bug

@miq-bot
Copy link
Member

miq-bot commented Jul 14, 2017

@ailisp Cannot apply the following label because they are not recognized: wip

@miq-bot miq-bot added the bug label Jul 14, 2017
@ailisp ailisp changed the title Fix configure network fails after a successful DHCP configuration [WIP] Fix configure network fails after a successful DHCP configuration Jul 14, 2017
@ailisp
Copy link
Member Author

ailisp commented Jul 14, 2017

What happens in ifdown:
screenshot_manageiq-20170706_2017-07-14_10 29 14
ifdown Success if run twice. And successfully setting static ipv6 after previously set by DHCP:
screenshot_manageiq-20170706_2017-07-14_10 46 41

@yrudman
Copy link
Contributor

yrudman commented Jul 14, 2017

@miq-bot add-label wip, bug, blocker

@miq-bot
Copy link
Member

miq-bot commented Jul 14, 2017

@yrudman Cannot apply the following labels because they are not recognized: wip, blocker

@@ -148,7 +148,7 @@ def start
#
# @return [Boolean] whether the command succeeded or not
def stop
Common.run(Common.cmd("ifdown"), :params => [@interface]).success?
Common.run(Common.cmd("ifconfig"), :params => [@interface, "down"]).success?
Copy link
Member

Choose a reason for hiding this comment

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

From the ifconfig man-page:

NOTE
       This program is obsolete!  For replacement check ip addr and ip link.  For statistics use ip -s link.

Can we find the newer version of this process rather than using an obsolete tool?

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, while testing this I found that ifconfig eth0 down didn't actually bring the network interface down.

A subsequent call to ifup eth0 failed because the interface was still active.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. What is the echo $? after ifconfig eth0 down in your test?

Copy link
Member

Choose a reason for hiding this comment

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

0, which is another reason it is so troubling ...

Copy link
Member Author

@ailisp ailisp Jul 17, 2017

Choose a reason for hiding this comment

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

I found ip a and ifconfig are living in two worlds. If you type ifconfig after a ifconfig down, eth0 has disappeared. But in ip a, it's still here, same as you.
screenshot_manageiq-20170714_2017-07-17_15 56 50

Copy link
Member Author

Choose a reason for hiding this comment

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

So if i use ip to shutdown/start an interface, and not use ifup & ifdown it should be fine. Let me test.

@carbonin
Copy link
Member

Specifically I did the following:

screenshot from 2017-07-17 15-06-29

@carbonin
Copy link
Member

@ailisp even if you us ip directly it still looks like the behavior will not be the same. ref: https://serverfault.com/questions/603906/ip-link-set-not-assigning-ip-address-but-ifup-does

@ailisp
Copy link
Member Author

ailisp commented Jul 17, 2017

@carbonin Right. I also found ip link set eth0 down doesn't shutdown eth0 ...

@ailisp
Copy link
Member Author

ailisp commented Jul 18, 2017

As @carbonin discovered. The first ifdown eth0 is because of it shut down processes listed in .pid file, including an dhcp client, which not exists. Thus it returns 1. In the second call, the pid file has been deleted, so it will return 0. It's safe to call it twice.

@ailisp ailisp changed the title [WIP] Fix configure network fails after a successful DHCP configuration Fix configure network fails after a successful DHCP configuration Jul 18, 2017
@ailisp
Copy link
Member Author

ailisp commented Jul 18, 2017

@carbonin tested after merge current master. Works fine.

return false unless stop
stop_success = stop
stop_success = stop unless stop_success
return false unless stop_success
Copy link
Member

Choose a reason for hiding this comment

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

So I opened a BZ that describes why we have to do this (https://bugzilla.redhat.com/show_bug.cgi?id=1472396)

Can you add a comment here with the BZ link explaining why we are trying twice?

Copy link
Member Author

@ailisp ailisp Jul 18, 2017

Choose a reason for hiding this comment

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

After configure both IPv4 and IPv6 as dhcp. The dhclient instance for IPv6 exits and leaves a file in /var/run/dhclient6-eth0.pid. Now if we run ifdown eth0 the command fails because ifdown-eth is failing to kill a process that is no-longer running. It will then delete that .pid file. So in the second run ifdown eth0 it will return 0 and success.

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1472396

stop_success = stop
# Stop twice because when configure both ipv4 and ipv6 as dhcp, dhcp client for ipv6
# exit and leave a /var/run/dhclient6-eth0.pid file. Then stop (ifdown eth0) will try
# to kill this exited process so it returns -1. In the second call, this `.pid' file
Copy link
Member

Choose a reason for hiding this comment

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

ifdown returns 1 in this case, not -1

Copy link
Member

Choose a reason for hiding this comment

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

Or just "returns a failure status".

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry for the typo. fixed

@carbonin carbonin self-assigned this Jul 18, 2017
@miq-bot
Copy link
Member

miq-bot commented Jul 18, 2017

Checked commits ailisp/linux_admin@568f56a~...f25b629 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@carbonin carbonin merged commit dc3b486 into ManageIQ:master Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants