From 95df86e1e030ab955ac09f145df37f3aef606c05 Mon Sep 17 00:00:00 2001 From: marcus Date: Tue, 30 Oct 2012 22:57:21 -0600 Subject: [PATCH] Summary: Fix virtual router trying to resolve own host name Detail: Several virtual router configuration commands, such as iptables commands, run slowly due to attempting to do a name lookup on the virtual router's hostname and having to time out. This is seen in the agent logs when a virtual router command is run, as "unable to resolve host r-410-VM" or similar. This can make for very slow router configuration, especially as the number of network rules grows. This change simply sets the router's name to the localhost IP in /etc/hosts BUG-ID : NONE Reviewed-by: Marcus Sorensen Reported-by: Marcus Sorensen Signed-off-by: Marcus Sorensen 1351659441 -0600 --- .../systemvm/debian/config/etc/init.d/cloud-early-config | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config index 7e5815682a8..d4af3a95755 100755 --- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config @@ -814,9 +814,18 @@ change_password() { fi } +set_etc_hosts() { + if [ -f /etc/hosts ]; then + host=`hostname -s`; + grep -q $host /etc/hosts || echo "127.0.0.1 $host" >> /etc/hosts; + fi +} + start() { # Clear /tmp for file lock rm -f /tmp/*.lock + # fix lookups for our hostname (iptables, etc) + set_etc_hosts local hyp=$(hypervisor) [ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out of early init" && exit 10 log_it "Detected that we are running inside $hyp guest"