You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2014/01/30 03:02:28 UTC
git commit: updated refs/heads/master to 121d887
Updated Branches:
refs/heads/master b38c033d5 -> 121d88743
CLOUDSTACK-5986: Make dnsmasq handle dnsmasq.leases when dhcp_release is available
The original issue has been exposed due to CloudStack VR would modify the
dnsmasq.leases, thus make it unsync with dnsmasq's memory lease.
Make the modification to let dnsmasq handle the lease file if dhcp_release is
available.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/121d8874
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/121d8874
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/121d8874
Branch: refs/heads/master
Commit: 121d88743a764e009717cc84440b1c7d5b1e42a4
Parents: b38c033
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Jan 29 16:15:24 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Jan 29 18:02:11 2014 -0800
----------------------------------------------------------------------
.../debian/config/etc/init.d/cloud-early-config | 10 ++++
.../debian/config/opt/cloud/bin/edithosts.sh | 53 +++++++++-----------
2 files changed, 35 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/121d8874/systemvm/patches/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
index df80a28..fa95fda 100755
--- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config
+++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
@@ -750,6 +750,16 @@ setup_dnsmasq() {
sed -i -e "/^dhcp-client-update/d" /etc/dnsmasq.conf
echo 'dhcp-client-update' >> /etc/dnsmasq.conf
fi
+
+ command -v dhcp_release > /dev/null 2>&1
+ no_dhcp_release=$?
+ if [ $no_dhcp_release -eq 0 -a -z "$ETH0_IP6" ]
+ then
+ echo 1 > /var/cache/cloud/dnsmasq_managed_lease
+ sed -i -e "/^leasefile-ro/d" /etc/dnsmasq.conf
+ else
+ echo 0 > /var/cache/cloud/dnsmasq_managed_lease
+ fi
}
setup_sshd(){
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/121d8874/systemvm/patches/debian/config/opt/cloud/bin/edithosts.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/edithosts.sh b/systemvm/patches/debian/config/opt/cloud/bin/edithosts.sh
index b82fb8e..8e7ddac 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/edithosts.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/edithosts.sh
@@ -80,8 +80,7 @@ fi
grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
no_redundant=$?
-command -v dhcp_release > /dev/null 2>&1
-no_dhcp_release=$?
+dnsmasq_managed_lease=`cat /var/cache/cloud/dnsmasq_managed_lease`
wait_for_dnsmasq () {
local _pid=$(pidof dnsmasq)
@@ -96,12 +95,7 @@ wait_for_dnsmasq () {
return 1
}
-if [ $ipv6 ]
-then
- no_dhcp_release=1
-fi
-
-if [ $no_dhcp_release -eq 0 ]
+if [ $dnsmasq_managed_lease ]
then
#release previous dhcp lease if present
logger -t cloud "edithosts: releasing $ipv4"
@@ -145,27 +139,30 @@ then
fi
fi
-#delete leases to supplied mac and ip addresses
-if [ $ipv4 ]
-then
- sed -i /$mac/d $DHCP_LEASES
- sed -i /"$ipv4 "/d $DHCP_LEASES
-fi
-if [ $ipv6 ]
+if [ $dnsmasq_managed_lease -eq 0 ]
then
- sed -i /$duid/d $DHCP_LEASES
- sed -i /"$ipv6 "/d $DHCP_LEASES
-fi
-sed -i /"$host "/d $DHCP_LEASES
+ #delete leases to supplied mac and ip addresses
+ if [ $ipv4 ]
+ then
+ sed -i /$mac/d $DHCP_LEASES
+ sed -i /"$ipv4 "/d $DHCP_LEASES
+ fi
+ if [ $ipv6 ]
+ then
+ sed -i /$duid/d $DHCP_LEASES
+ sed -i /"$ipv6 "/d $DHCP_LEASES
+ fi
+ sed -i /"$host "/d $DHCP_LEASES
-#put in the new entry
-if [ $ipv4 ]
-then
- echo "0 $mac $ipv4 $host *" >> $DHCP_LEASES
-fi
-if [ $ipv6 ]
-then
- echo "0 $duid $ipv6 $host *" >> $DHCP_LEASES
+ #put in the new entry
+ if [ $ipv4 ]
+ then
+ echo "0 $mac $ipv4 $host *" >> $DHCP_LEASES
+ fi
+ if [ $ipv6 ]
+ then
+ echo "0 $duid $ipv6 $host *" >> $DHCP_LEASES
+ fi
fi
#edit hosts file as well
@@ -215,7 +212,7 @@ pid=$(pidof dnsmasq)
if [ "$pid" != "" ]
then
# use SIGHUP to avoid service outage if dhcp_release is available.
- if [ $no_dhcp_release -eq 0 ]
+ if [ $dnsmasq_managed_lease ]
then
kill -HUP $pid
else