Merge ~andreserl/maas:workaround_lp1711760 into maas:master

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: 695ba020fd0de5f907a215e16ba9a87a21a04f0f
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~andreserl/maas:workaround_lp1711760
Merge into: maas:master
Diff against target: 35 lines (+24/-0)
1 file modified
src/metadataserver/user_data/templates/base_user_data.sh (+24/-0)
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+331968@code.launchpad.net

Commit message

LP: #1711760 - Workaround bug in resolvconf where nameservers are not populated in ephemeral environments

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :

I havn't tested this but it looks good.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
Scott Moser (smoser) wrote :

I realize this is just a quick hack/workaround.
but something I think is probably better woudl be to just read the values in /run/net-*

i'd be kind of afraid of dhclient downing the interface (especially if for some reason it failed to get a lease).

maybe:

for i in /run/net-*.conf; do
   [ -f "$f" ] || continue
   # use a subshell to avoid contaminating this environment
   ( . "$f"
     for ns in "$IPV4DNS0" "$IPV4DNS1" "$IPV6DNS0" "$IPV6DNS1"; do
       [ -z "$ns" -o "$ns" = "0.0.0.0" ] && continue
       echo "nameserver $ns" >> /etc/resolv.conf
   )
done

Revision history for this message
Scott Moser (smoser) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/user_data/templates/base_user_data.sh b/src/metadataserver/user_data/templates/base_user_data.sh
2index e152a38..2a8e911 100644
3--- a/src/metadataserver/user_data/templates/base_user_data.sh
4+++ b/src/metadataserver/user_data/templates/base_user_data.sh
5@@ -12,6 +12,30 @@ export PATH="$BIN_D:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
6
7 mkdir -p "$BIN_D"
8
9+#### FIXME: Remove work around when the issue is fixed in resolvconf ###
10+#
11+# LP: #1711760
12+# Work around issue where resolv.conf is not set on the ephemeral environment
13+#
14+# First check if a nameserver is set in resolv.conf
15+if ! echo /etc/resolv.conf | grep -qs "nameserver"; then
16+ # If it is not, obtain the MAC address of the PXE boot interface
17+ mac_address=$(cat /proc/cmdline | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')
18+
19+ # Search for the NIC name of the PXE boot interface
20+ for nic in /sys/class/net/*; do
21+ nic_mac=$(cat $nic/address)
22+ if [ "$nic_mac" == "$mac_address" ]; then
23+ # Get the interface name and ask dhclient to refresh the lease
24+ interface=$(echo $nic | cut -d'/' -f5)
25+ dhclient $interface || true
26+ break
27+ fi
28+ done
29+fi
30+
31+######################
32+
33 # Ensure that invocations of apt-get are not interactive by default,
34 # here and in all subprocesses.
35 export DEBIAN_FRONTEND=noninteractive

Subscribers

People subscribed via source and target branches