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

Subscribers

People subscribed via source and target branches