Message ID | 1507288103-16077-1-git-send-email-guru@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,1/2] ovs-ctl.in: Call 'hostname -f' after vswitchd starts. | expand |
On Fri, Oct 06, 2017 at 04:08:22AM -0700, Gurucharan Shetty wrote: > Currently we call 'hostname -f' when ovs-vswitchd is not > running. If you are using ovs-vswitchd to provide your > primary networking, then 'hostname -f' will "hang" till it > times out. On the system this issue was discovered, this was > as long as 40 seconds. This is a problem during OVS restarts > or upgrades. > > This commit calls 'hostname -f' after ovs-vswitchd has started. > > Signed-off-by: Gurucharan Shetty <guru@ovn.org> Thanks for figuring this out. It looks like every start_forwarding call is now followed by set_hostname. Would it make sense for start_forwarding to call set_hostname itself? I guess that setting external-ids:hostname is not something that has to happen synchronously. Would it make sense to do it in the background, e.g. "set_hostname &", so that if DNS is slow or unavailable (even after starting ovs-vswitchd), it doesn't slow down startup? Acked-by: Ben Pfaff <blp@ovn.org>
On 6 October 2017 at 15:25, Ben Pfaff <blp@ovn.org> wrote: > On Fri, Oct 06, 2017 at 04:08:22AM -0700, Gurucharan Shetty wrote: > > Currently we call 'hostname -f' when ovs-vswitchd is not > > running. If you are using ovs-vswitchd to provide your > > primary networking, then 'hostname -f' will "hang" till it > > times out. On the system this issue was discovered, this was > > as long as 40 seconds. This is a problem during OVS restarts > > or upgrades. > > > > This commit calls 'hostname -f' after ovs-vswitchd has started. > > > > Signed-off-by: Gurucharan Shetty <guru@ovn.org> > > Thanks for figuring this out. > > It looks like every start_forwarding call is now followed by > set_hostname. Would it make sense for start_forwarding to call > set_hostname itself? > Yes. I will do that. > > I guess that setting external-ids:hostname is not something that has to > happen synchronously. Would it make sense to do it in the background, > e.g. "set_hostname &", so that if DNS is slow or unavailable (even after > starting ovs-vswitchd), it doesn't slow down startup? > Makes sense too. I will do that. > > Acked-by: Ben Pfaff <blp@ovn.org> > I did the above 2 and applied it to master. I will also backport to relevent branches. Thanks a lot!
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index dc1d02c..97c3c09 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -75,6 +75,12 @@ ovs_vsctl () { ovs-vsctl --no-wait "$@" } +set_hostname () { + # 'hostname -f' needs network connectivity to work. So we should + # call this only after ovs-vswitchd is running. + ovs_vsctl set Open_vSwitch . external-ids:hostname=$(hostname -f) +} + set_system_ids () { set ovs_vsctl set Open_vSwitch . @@ -108,8 +114,6 @@ set_system_ids () { esac set "$@" external-ids:system-id="\"$SYSTEM_ID\"" - set "$@" external-ids:hostname="\"$(hostname -f)\"" - set "$@" external-ids:rundir="\"$rundir\"" if test X"$SYSTEM_TYPE" != X; then @@ -382,6 +386,7 @@ force_reload_kmod () { else log_warning_msg "Failed to save configuration, not replacing kernel module" start_forwarding + set_hostname add_managers exit 1 fi @@ -405,6 +410,7 @@ force_reload_kmod () { # Start vswitchd by asking it to wait till flow restore is finished. flow_restore_wait start_forwarding || return 1 + set_hostname # Restore saved flows and inform vswitchd that we are done. restore_flows @@ -438,6 +444,7 @@ restart () { # Start vswitchd by asking it to wait till flow restore is finished. flow_restore_wait start_forwarding || return 1 + set_hostname # Restore saved flows and inform vswitchd that we are done. restore_flows @@ -695,6 +702,7 @@ case $command in start) start_ovsdb || exit 1 start_forwarding || exit 1 + set_hostname add_managers ;; stop)
Currently we call 'hostname -f' when ovs-vswitchd is not running. If you are using ovs-vswitchd to provide your primary networking, then 'hostname -f' will "hang" till it times out. On the system this issue was discovered, this was as long as 40 seconds. This is a problem during OVS restarts or upgrades. This commit calls 'hostname -f' after ovs-vswitchd has started. Signed-off-by: Gurucharan Shetty <guru@ovn.org> --- utilities/ovs-ctl.in | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)