-
Notifications
You must be signed in to change notification settings - Fork 31
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
Conversation
@ailisp Cannot apply the following label because they are not recognized: wip |
@miq-bot add-label wip, bug, blocker |
@yrudman Cannot apply the following labels because they are not recognized: wip, blocker |
lib/linux_admin/network_interface.rb
Outdated
@@ -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? |
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.
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?
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.
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.
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.
Interesting. What is the echo $?
after ifconfig eth0 down
in your 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.
0
, which is another reason it is so troubling ...
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.
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.
So if i use ip
to shutdown/start an interface, and not use ifup & ifdown
it should be fine. Let me test.
@ailisp even if you us |
@carbonin Right. I also found |
As @carbonin discovered. The first |
@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 |
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.
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?
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.
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 |
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.
ifdown returns 1 in this case, not -1
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.
Or just "returns a failure status".
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.
sorry for the typo. fixed
Checked commits ailisp/linux_admin@568f56a~...f25b629 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
ISSUE: After a successful DHCP configuration, if you configure network using static ipv6 it will fails. That fails is actually
ifdown
returns1
indicate previous setting to network (DHCP) one is not successfully shutdown. However, actually it does if you runifconfig
at this time. This is why the network configuration becomes empty in appliance console status:ifdown
fails soNetworkInterfaceRH.save
returnsfalse
immediately without start upeth0
using old configuration or new configuration. Afterifdown
returns1
if we run anotherifdown
it will return0
and subsequentifup
new configuration works.BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1464999
\cc @yrudman @carbonin
@miq-bot add-label wip,bug