Ido Barkan has uploaded a new change for review. Change subject: fixing race while sampling interfaces ......................................................................
fixing race while sampling interfaces The race condition is that a link is reported by getLinks and then it is no longer there by the time InterfaceSample is called Change-Id: I059a5bfa4c140d88f512dc9a51d18f02956710de Signed-off-by: ibarkan <[email protected]> --- M vdsm/virt/sampling.py 1 file changed, 15 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/36138/1 diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py index eac4873..f6892e6 100644 --- a/vdsm/virt/sampling.py +++ b/vdsm/virt/sampling.py @@ -215,6 +215,20 @@ raise ValueError('Boot time not present') +def _get_interfaces_and_samples(): + links_and_samples = dict() + for link in getLinks(): + try: + links_and_samples[link.name] = InterfaceSample(link) + except IOError as e: + # this handles a race condition where the device is now no + # longer exists and netlink fails to fetch it + if e.errno == errno.ENODEV: + continue + raise + return links_and_samples + + class HostSample(TimedSample): """ A sample of host-related statistics. @@ -243,8 +257,7 @@ :type pid: int """ TimedSample.__init__(self) - self.interfaces = dict( - (link.name, InterfaceSample(link)) for link in getLinks()) + self.interfaces = _get_interfaces_and_samples() self.pidcpu = PidCpuSample(pid) self.totcpu = TotalCpuSample() meminfo = utils.readMemInfo() -- To view, visit http://gerrit.ovirt.org/36138 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I059a5bfa4c140d88f512dc9a51d18f02956710de Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ido Barkan <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
