Auto-detect the MTU on the default interface and use that for the lxd
bridge
Signed-off-by: Adam Israel <adam.israel@canonical.com>
Change-Id: If01abbd67fcdc86d0e953f3753bf5c5da1192191
diff --git a/jenkins/VCA/start_build b/jenkins/VCA/start_build
index 45b0e94..d6ccfd8 100755
--- a/jenkins/VCA/start_build
+++ b/jenkins/VCA/start_build
@@ -56,6 +56,16 @@
systemctl enable lxd-bridge
systemctl start lxd-bridge
+DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
+DEFAULT_MTU=$( ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
+
+INFO "Setting lxdbr0 MTU to $DEFAULT_MTU"
+ifconfig lxdbr0 mtu $DEFAULT_MTU
+
+# Make the MTU change persistent between reboots
+sed -i '/ifconfig lxdbr0 mtu/d' /etc/rc.local
+sed -i "$ i ifconfig lxdbr0 mtu $DEFAULT_MTU" /etc/rc.local
+
INFO "Pre-caching Ubuntu:16.04 image (this may take several minutes)..."
# Setup a daily cron to update the cached image