Change in vdsm[master]: vdsm-restore-net-config: wait for links with netlink monitor
phoracek at redhat.com
phoracek at redhat.com
Wed Feb 24 13:57:21 UTC 2016
Petr Horáček has uploaded a new change for review.
Change subject: vdsm-restore-net-config: wait for links with netlink monitor
......................................................................
vdsm-restore-net-config: wait for links with netlink monitor
Change-Id: I1c45430925a55bb54995b91a061bc15affe15763
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M vdsm/vdsm-restore-net-config
1 file changed, 22 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/53968/1
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index a64f7ce..3515f9a 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -25,7 +25,6 @@
import os
import re
import threading
-import time
import errno
import six
@@ -35,12 +34,12 @@
from vdsm.netinfo import nics, misc
from vdsm.netinfo.misc import ipv6_supported
from vdsm.netinfo.cache import CachingNetInfo
+from vdsm.netlink import monitor
from vdsm import kernelconfig
from vdsm.constants import P_VDSM_RUN
from vdsm.netconfpersistence import RunningConfig, PersistentConfig, \
CONF_PERSIST_DIR, BaseConfig
from vdsm import sysctl
-from vdsm.utils import monotonic_time
import hostdev
# Ifcfg persistence restoration
@@ -49,8 +48,6 @@
# Unified persistence restoration
from vdsm.network.api import setupNetworks, change_numvfs
-
-_ALL_DEVICES_UP_TIMEOUT = 5
_NETS_RESTORED_MARK = os.path.join(P_VDSM_RUN, 'nets_restored')
_VIRTUAL_FUNCTIONS_PATH = os.path.join(CONF_PERSIST_DIR, 'virtual_functions')
@@ -324,20 +321,27 @@
def _wait_for_for_all_devices_up(links):
- timeout = monotonic_time() + _ALL_DEVICES_UP_TIMEOUT
- down_links = _get_links_with_state_down(links)
-
- # TODO: use netlink monitor here might be more elegant (not available in
- # TODO: 3.5)
- while down_links and monotonic_time() < timeout:
- logging.debug("waiting for %s to be up.", down_links)
- time.sleep(1)
- down_links = _get_links_with_state_down(links)
-
- if down_links:
- logging.warning("Not all devices are up. VDSM might restore them "
- "although they were not changed since they were "
- "persisted.")
+ try:
+ with monitor.Monitor(groups=('link',), timeout=5) as mon:
+ down_links = _get_links_with_state_down(links)
+ logging.debug("waiting for %s to be up.", down_links)
+ if not down_links:
+ mon.stop()
+ for event in mon:
+ link_name = event.get('label')
+ if (link_name in down_links and
+ event.get('event') == 'new_link' and
+ event.get('state') == 'up'):
+ down_links.remove(link_name)
+ if not down_links:
+ mon.stop()
+ except monitor.MonitorError as e:
+ if e[0] == monitor.E_TIMEOUT:
+ logging.warning("Not all devices are up. VDSM might restore them "
+ "although they were not changed since they were "
+ "persisted.")
+ else:
+ raise
else:
logging.debug("All devices are up.")
--
To view, visit https://gerrit.ovirt.org/53968
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c45430925a55bb54995b91a061bc15affe15763
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
More information about the vdsm-patches
mailing list