[PATCH rhel7-branch] Check for device state races also for Dhcp4Config (#1005681)

Brian C. Lane bcl at redhat.com
Tue Sep 10 18:36:20 UTC 2013


On Tue, Sep 10, 2013 at 12:16:16PM +0200, Vratislav Podzimek wrote:
> On Tue, 2013-09-10 at 12:05 +0200, Radek Vykydal wrote:
> > ---
> >  pyanaconda/nm.py | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
> > index e91aa26..24ca1aa 100644
> > --- a/pyanaconda/nm.py
> > +++ b/pyanaconda/nm.py
> > @@ -357,7 +357,14 @@ def nm_ntp_servers_from_dhcp():
> >      for device in active_devices:
> >          # harvest NTP server addresses from DHCPv4
> >          dhcp4_path = nm_device_property(device, "Dhcp4Config")
> > -        options = _get_property(dhcp4_path, "Options", ".DHCP4Config")
> > +        try:
> > +            options = _get_property(dhcp4_path, "Options", ".DHCP4Config")
> > +        except GLib.GError as e:
> > +            # checking the device state (has to be ACTIVATED) is racy
> > +            if "org.freedesktop.DBus.Error.UnknownMethod" in e.message:
> > +                options = None
> > +            else:
> > +                raise
> We were discussing with Radek that it might be better to do the 'if
> "org.freedesktop.DBus.Error.UnknownMethod" in e.message:' check in the
> _get_property() method and raise some special "CannotCallGetError"
> instead that could be caught by the callers without doing the low-level
> check of GLib.GError's message.

That sounds like a good idea to me.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130910/cc3250b2/attachment.sig>


More information about the anaconda-patches mailing list