CS-16400: Fix LB service using port 8080

Also added license header for passwd_server_ip

Ported from:

commit 1072ec7ae3
Author: Sheng Yang <sheng.yang@citrix.com>
Date:   Wed Sep 12 11:15:33 2012 -0700

    CS-16318: Update the fix with some tweak

    1. The old fix run cloud-passwd-srvr twice because cloud-passwd-srvr is
still in the list of enabled_svcs

    2. The lock should be applied on serve_password.sh, which controlled the
accessing to the password. Applied on the MASTER/BACKUP switch is useless, two
instance of serve_password.sh would still able to access the password file at
the same time.

    3. Password service is a part of redundant router state transition process
now, so if the service failed to start, then the transition failed.

    4. Restart password service should be put before restart dnsmasq, which
would sent out DHCP offer to the user vms. If user VMs got the DHCP offer first
but failed to get password, there would be an issue.

    Reviewed-by: Anthony Xu

commit fa94da1140
Author: Jayapal Reddy <jayapalreddy.uradi@citrix.com>
Date:   Wed Sep 12 17:57:03 2012 +0530

    Bug:CS-16318 Starting password server on the both IPs in RRVM
    Reviewed-by: Abhi

Conflicts:

	patches/systemvm/debian/config/opt/cloud/bin/passwd_server
This commit is contained in:
Sheng Yang 2012-09-26 15:26:30 -07:00
parent f0e928461a
commit 435e4f6868
7 changed files with 56 additions and 22 deletions

View File

@ -33,11 +33,11 @@ start() {
[ "$ENABLED" != 0 ] || exit 0
pid=$(getpid)
[ "$pid" != "" ] && echo "Password server is already running (pid=$pid)" && return 0
nohup bash /opt/cloud/bin/passwd_server&
nohup bash /opt/cloud/bin/passwd_server &
}
getpid() {
pid=$(ps -ef | grep passwd_server | grep -v grep | awk '{print $2}')
pid=$(ps -ef | grep passwd_server_ip | grep -v grep | awk '{print $2}')
echo $pid
}

View File

@ -16,18 +16,8 @@
# specific language governing permissions and limitations
# under the License.
. /etc/default/cloud-passwd-srvr
while [ "$ENABLED" == "1" ]
do
socat -lf /var/log/cloud.log TCP4-LISTEN:8080,reuseaddr,crnl,bind=0.0.0.0 SYSTEM:"/opt/cloud/bin/serve_password.sh \"\$SOCAT_PEERADDR\""
rc=$?
if [ $rc -ne 0 ]
then
logger -t cloud "Password server failed with error code $rc. Restarting socat..."
sleep 3
fi
. /etc/default/cloud-passwd-srvr
done
ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}' ); echo $ips
for ip in $ips; do
addr=$(echo $ip | awk -F'/' '{print $1}')
/opt/cloud/bin/passwd_server_ip $addr &
done;

View File

@ -0,0 +1,32 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
. /etc/default/cloud-passwd-srvr
addr=$1;
while [ "$ENABLED" == "1" ]
do
socat -lf /var/log/cloud.log TCP4-LISTEN:8080,reuseaddr,crnl,bind=$addr SYSTEM:"/opt/cloud/bin/serve_password.sh \"\$SOCAT_PEERADDR\""
rc=$?
if [ $rc -ne 0 ]
then
logger -t cloud "Password server failed with error code $rc. Restarting socat..."
sleep 3
fi
. /etc/default/cloud-passwd-srvr
done

View File

@ -70,7 +70,6 @@ routing_svcs() {
grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
RROUTER=$?
chkconfig cloud off
chkconfig cloud-passwd-srvr on ;
chkconfig haproxy on ;
chkconfig ssh on
chkconfig nfs-common off
@ -78,19 +77,21 @@ routing_svcs() {
if [ $RROUTER -eq 0 ]
then
chkconfig dnsmasq off
chkconfig cloud-passwd-srvr off
chkconfig keepalived on
chkconfig conntrackd on
chkconfig postinit on
echo "keepalived conntrackd postinit" > /var/cache/cloud/enabled_svcs
echo "dnsmasq " > /var/cache/cloud/disabled_svcs
echo "dnsmasq cloud-passwd-srvr" > /var/cache/cloud/disabled_svcs
else
chkconfig dnsmasq on
chkconfig cloud-passwd-srvr on
chkconfig keepalived off
chkconfig conntrackd off
echo "dnsmasq " > /var/cache/cloud/enabled_svcs
echo "dnsmasq cloud-passwd-srvr " > /var/cache/cloud/enabled_svcs
echo "keepalived conntrackd " > /var/cache/cloud/disabled_svcs
fi
echo "cloud-passwd-srvr ssh haproxy apache2" >> /var/cache/cloud/enabled_svcs
echo "ssh haproxy apache2" >> /var/cache/cloud/enabled_svcs
echo "cloud nfs-common portmap" > /var/cache/cloud/disabled_svcs
}

View File

@ -20,6 +20,15 @@
# set -x
source /root/func.sh
lock="passwdlock"
locked=$(getLockFile $lock)
if [ "$locked" != "1" ]
then
exit 1
fi
PASSWD_FILE=/var/cache/cloud/passwords
# $1 filename
@ -91,4 +100,4 @@ fi
# echo -e \"\\\"\\\n\\\"\"
exit 0
unlock_exit 0 $lock $locked

View File

@ -21,4 +21,5 @@ while read i
do
ifconfig $i down
done < /tmp/iflist
service cloud-passwd-srvr stop
service dnsmasq stop

View File

@ -25,4 +25,5 @@ do
ifup $i
done < /tmp/iflist
ip route add default via [GATEWAY] dev eth2 && \
service cloud-passwd-srvr restart && \
service dnsmasq restart