[node-patches] Change in ovirt-node[master]: network: Fix resolv.conf reloading

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Feb 12 21:50:18 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: network: Fix resolv.conf reloading
......................................................................

network: Fix resolv.conf reloading

resolv.conf is only reload by glibc on the first lookup request. This
leads to problems in cases where resolv.conf changes between after the
first lookup request, because the changes are not picked up by glibc.
E.g. any new or change nameserver will not be picked up, if resolv.conf
changed during one python process.

See also:
http://www.redhat.com/archives/rhl-devel-list/2009-January/msg01256.html

Change-Id: I1a89bd1bbc4bcf650af7539a8bf4cab8c43eaca1
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/utils/network.py
2 files changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/93/11993/1

diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 26f1b2d..1267972 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -345,6 +345,7 @@
 
             def commit(self):
                 utils.AugeasWrapper.force_reload()
+                utils.network.reset_resolver()
 
         tx = utils.Transaction("Applying new network configuration")
         tx.append(ConfigureNIC())
@@ -411,6 +412,8 @@
                 ovirtfunctions.ovirt_store_config("/etc/sysconfig/network")
                 ovirtfunctions.ovirt_store_config("/etc/hosts")
 
+                utils.network.reset_resolver()
+
         tx = utils.Transaction("Configuring hostname")
         tx.append(UpdateHostname(hostname))
         return tx
@@ -461,6 +464,8 @@
                 net = onet.Network()
                 net.configure_dns()
 
+                utils.network.reset_resolver()
+
         tx = utils.Transaction("Configuring nameservers")
         tx.append(ConfigureNameservers())
         return tx
@@ -504,6 +509,8 @@
                 config.network.nameservers(servers)
                 utils.fs.Config().persist("/etc/resolv.conf")
 
+                utils.network.reset_resolver()
+
         class UpdatePeerDNS(utils.Transaction.Element):
             title = "Update PEERDNS statement in ifcfg-* files"
 
diff --git a/scripts/tui/src/ovirt/node/utils/network.py b/scripts/tui/src/ovirt/node/utils/network.py
index d810296..46e17d5 100644
--- a/scripts/tui/src/ovirt/node/utils/network.py
+++ b/scripts/tui/src/ovirt/node/utils/network.py
@@ -499,3 +499,18 @@
     if new_hostname:
         utils.process.call("hostname %s" % new_hostname)
     return utils.process.pipe("hostname").strip()
+
+
+# http://git.fedorahosted.org/cgit/smolt.git/diff/?
+# id=aabd536e21f362f7bac18a2dbc1a55cbdb9ae385
+def reset_resolver():
+    '''Attempt to reset the system hostname resolver.
+    returns 0 on success, or -1 if an error occurs.'''
+    import ctypes
+    try:
+        resolv = ctypes.CDLL("libresolv.so.2")
+        r = resolv.__res_init()
+    except (OSError, AttributeError):
+        print "Warning: could not find __res_init in libresolv.so.2"
+        r = -1
+    return r


--
To view, visit http://gerrit.ovirt.org/11993
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a89bd1bbc4bcf650af7539a8bf4cab8c43eaca1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list