summaryrefslogtreecommitdiffstats
path: root/roles/openshift_node_dnsmasq
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-08-18 16:25:03 -0400
committerScott Dodson <sdodson@redhat.com>2017-08-21 16:13:07 -0400
commitf0fe4dbd880b8ab1ae450ee2bf3743654358612d (patch)
tree1a7a7d8ed4b813d6c8a066274fd3f79b523c7bf3 /roles/openshift_node_dnsmasq
parent23da41c1fb3736b10e07774000e3a2bca028806e (diff)
downloadopenshift-f0fe4dbd880b8ab1ae450ee2bf3743654358612d.tar.gz
openshift-f0fe4dbd880b8ab1ae450ee2bf3743654358612d.tar.bz2
openshift-f0fe4dbd880b8ab1ae450ee2bf3743654358612d.tar.xz
openshift-f0fe4dbd880b8ab1ae450ee2bf3743654358612d.zip
If IP4_NAMESERVERS are unset then pull the value from /etc/resolv.conf
This will happen whenever someone has directly modified /etc/resolv.conf Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1480438
Diffstat (limited to 'roles/openshift_node_dnsmasq')
-rwxr-xr-xroles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh65
1 files changed, 34 insertions, 31 deletions
diff --git a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
index 4aab8f2e9..61d2a5b51 100755
--- a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
+++ b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
@@ -46,9 +46,7 @@ if [[ $2 =~ ^(up|dhcp4-change|dhcp6-change)$ ]]; then
def_route=$(/sbin/ip route list match 0.0.0.0/0 | awk '{print $3 }')
def_route_int=$(/sbin/ip route get to ${def_route} | awk '{print $3}')
def_route_ip=$(/sbin/ip route get to ${def_route} | awk '{print $5}')
- if [[ ${DEVICE_IFACE} == ${def_route_int} && \
- -n "${IP4_NAMESERVERS}" && \
- "${IP4_NAMESERVERS}" != "${def_route_ip}" ]]; then
+ if [[ ${DEVICE_IFACE} == ${def_route_int} ]]; then
if [ ! -f /etc/dnsmasq.d/origin-dns.conf ]; then
cat << EOF > /etc/dnsmasq.d/origin-dns.conf
no-resolv
@@ -61,35 +59,40 @@ EOF
NEEDS_RESTART=1
fi
- ######################################################################
- # Write out default nameservers for /etc/dnsmasq.d/origin-upstream-dns.conf
- # and /etc/origin/node/resolv.conf in their respective formats
- for ns in ${IP4_NAMESERVERS}; do
- if [[ ! -z $ns ]]; then
- echo "server=${ns}" >> $UPSTREAM_DNS_TMP
- echo "nameserver ${ns}" >> $NEW_NODE_RESOLV_CONF
+ # If network manager doesn't know about the nameservers then the best
+ # we can do is grab them from /etc/resolv.conf but only if we've got no
+ # watermark
+ if ! grep -q '99-origin-dns.sh' /etc/resolv.conf; then
+ if [[ -z "${IP4_NAMESERVERS}" || "${IP4_NAMESERVERS}" == "${def_route_ip}" ]]; then
+ IP4_NAMESERVERS=`grep '^nameserver ' /etc/resolv.conf | awk '{ print $2 }'`
+ fi
+ ######################################################################
+ # Write out default nameservers for /etc/dnsmasq.d/origin-upstream-dns.conf
+ # and /etc/origin/node/resolv.conf in their respective formats
+ for ns in ${IP4_NAMESERVERS}; do
+ if [[ ! -z $ns ]]; then
+ echo "server=${ns}" >> $UPSTREAM_DNS_TMP
+ echo "nameserver ${ns}" >> $NEW_NODE_RESOLV_CONF
+ fi
+ done
+ # Sort it in case DNS servers arrived in a different order
+ sort $UPSTREAM_DNS_TMP > $UPSTREAM_DNS_TMP_SORTED
+ sort $UPSTREAM_DNS > $CURRENT_UPSTREAM_DNS_SORTED
+ # Compare to the current config file (sorted)
+ NEW_DNS_SUM=`md5sum ${UPSTREAM_DNS_TMP_SORTED} | awk '{print $1}'`
+ CURRENT_DNS_SUM=`md5sum ${CURRENT_UPSTREAM_DNS_SORTED} | awk '{print $1}'`
+ if [ "${NEW_DNS_SUM}" != "${CURRENT_DNS_SUM}" ]; then
+ # DNS has changed, copy the temp file to the proper location (-Z
+ # sets default selinux context) and set the restart flag
+ cp -Z $UPSTREAM_DNS_TMP $UPSTREAM_DNS
+ NEEDS_RESTART=1
+ fi
+ # compare /etc/origin/node/resolv.conf checksum and replace it if different
+ NEW_NODE_RESOLV_CONF_MD5=`md5sum ${NEW_NODE_RESOLV_CONF}`
+ OLD_NODE_RESOLV_CONF_MD5=`md5sum /etc/origin/node/resolv.conf`
+ if [ "${NEW_NODE_RESOLV_CONF_MD5}" != "${OLD_NODE_RESOLV_CONF_MD5}" ]; then
+ cp -Z $NEW_NODE_RESOLV_CONF /etc/origin/node/resolv.conf
fi
- done
-
- # Sort it in case DNS servers arrived in a different order
- sort $UPSTREAM_DNS_TMP > $UPSTREAM_DNS_TMP_SORTED
- sort $UPSTREAM_DNS > $CURRENT_UPSTREAM_DNS_SORTED
-
- # Compare to the current config file (sorted)
- NEW_DNS_SUM=`md5sum ${UPSTREAM_DNS_TMP_SORTED} | awk '{print $1}'`
- CURRENT_DNS_SUM=`md5sum ${CURRENT_UPSTREAM_DNS_SORTED} | awk '{print $1}'`
- if [ "${NEW_DNS_SUM}" != "${CURRENT_DNS_SUM}" ]; then
- # DNS has changed, copy the temp file to the proper location (-Z
- # sets default selinux context) and set the restart flag
- cp -Z $UPSTREAM_DNS_TMP $UPSTREAM_DNS
- NEEDS_RESTART=1
- fi
-
- # compare /etc/origin/node/resolv.conf checksum and replace it if different
- NEW_NODE_RESOLV_CONF_MD5=`md5sum ${NEW_NODE_RESOLV_CONF}`
- OLD_NODE_RESOLV_CONF_MD5=`md5sum /etc/origin/node/resolv.conf`
- if [ "${NEW_NODE_RESOLV_CONF_MD5}" != "${OLD_NODE_RESOLV_CONF_MD5}" ]; then
- cp -Z $NEW_NODE_RESOLV_CONF /etc/origin/node/resolv.conf
fi
if ! `systemctl -q is-active dnsmasq.service`; then