Skip to content

Commit 9707488

Browse files
committed
Production upgrade steps
1 parent 373d826 commit 9707488

26 files changed

+170
-144
lines changed

04-lbaas-upgrade/haproxy_proxies.j2.patch

-11
This file was deleted.

04-lbaas-upgrade/lbaas-migration.sh

-132
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
export LBAAS_HOSTS=$(sudo mysql neutron -sNe 'select host from agents where `binary` = "neutron-lbaas-agent" and TIMESTAMPDIFF(SECOND, heartbeat_timestamp, NOw()) < 300' | awk 1 ORS=',')
4+
export LBAAS_HOSTS_COUNT=$(sudo mysql neutron -sNe 'select count(*) from agents where `binary` = "neutron-lbaas-agent" and TIMESTAMPDIFF(SECOND, heartbeat_timestamp, NOw()) < 300')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# "clean' pools so that they have at most 1 health monitor
2+
3+
#neutron lb-healthmonitor-disassociate bf5eddd4-2e9d-4836-8d21-d9a8cec2162e c14f298c-f922-4743-9239-555a0670c7fb
4+
#...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# patch lbaas agent (bug 1600326)

04-lbaas-upgrade/watch_haproxy.sh 04-lbaas-upgrade/migration_init/3-watch-haproxy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ VERSION=""
1717
[ "$1" == "v2" ] && VERSION="v2/"
1818

1919
#LBAAS_HOSTS=$(sudo mysql neutron -sNe 'select host from agents where `binary` = "neutron-lbaas-agent" and TIMESTAMPDIFF(SECOND, heartbeat_timestamp, NOw()) < 600' | awk 1 ORS=',')
20-
LBAAS_HOSTS=$(sudo mysql neutron -sNe 'select host from agents where `binary` = "neutron-lbaas-agent"' | awk 1 ORS=',')
20+
#LBAAS_HOSTS=$(sudo mysql neutron -sNe 'select host from agents where `binary` = "neutron-lbaas-agent"' | awk 1 ORS=',')
2121

2222
while true; do
2323
if [ -z "$VERSION" ]; then
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
export LBAAS_HOSTS=$(mysql neutron -sNe 'select host from agents where `binary` = "neutron-lbaas-agent" and TIMESTAMPDIFF(SECOND, heartbeat_timestamp, NOw()) < 300' | awk 1 ORS=',')
4+
export LBAAS_HOSTS_COUNT=$(mysql neutron -sNe 'select count(*) from agents where `binary` = "neutron-lbaas-agent" and TIMESTAMPDIFF(SECOND, heartbeat_timestamp, NOw()) < 300')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
sudo cp ../4aff599b9845_lbaas_v1_to_v2_migration.py /usr/lib/python2.7/site-packages/neutron_lbaas/db/migration/alembic_migrations/versions/liberty/expand/
4+
sudo sed -i 's/3345facd0452/4aff599b9845/g' /usr/lib/python2.7/site-packages/neutron_lbaas/db/migration/alembic_migrations/versions/HEADS
5+
6+
sudo neutron-db-manage --subproject neutron-lbaas upgrade head
7+
8+
sudo rm /usr/lib/python2.7/site-packages/neutron_lbaas/db/migration/alembic_migrations/versions/liberty/expand/4aff599b9845_lbaas_v1_to_v2_migration.py
9+
sudo sed -i 's/4aff599b9845/3345facd0452/g' /usr/lib/python2.7/site-packages/neutron_lbaas/db/migration/alembic_migrations/versions/HEADS
10+
sudo mysql neutron -e "update alembic_version_lbaas set version_num = '3345facd0452' where version_num = '4aff599b9845'"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
backup_dir=backup-$(hostname)
4+
mkdir $backup_dir
5+
6+
sudo mysqldump --no-create-info --no-create-db --extended-insert --single-transaction --complete-insert --insert-ignore \
7+
neutron members poolmonitorassociations poolstatisticss pools poolloadbalanceragentbindings vips healthmonitors | gzip > $backup_dir/neutron-lbaas-v1-pre-upgrade-backup.sql.gz
8+
9+
sudo mysqldump --add-drop-database heat | gzip > $backup_dir/heat.sql.gz
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
test -z "$LBAAS_HOSTS" && echo "LBAAS_HOSTS env variable missing!" && exit
4+
5+
ansible -i "$LBAAS_HOSTS" all -b -K -m script -a ansible-switch-to-v2-agent.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
sudo cp -n /etc/neutron/neutron.conf /etc/neutron/neutron.conf.lbaasv1
4+
sudo cp -n /etc/neutron/neutron_lbaas.conf /etc/neutron/neutron_lbaas.conf.lbaasv1
5+
sudo cp -n /etc/neutron/lbaas_agent.ini /etc/neutron/lbaas_agent.ini.lbaasv1
6+
7+
sudo crudini --set /etc/neutron/neutron.conf DEFAULT service_plugins router,neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2
8+
sudo crudini --set /etc/neutron/neutron_lbaas.conf service_providers service_provider LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
9+
sudo crudini --set /etc/neutron/lbaas_agent.ini DEFAULT device_driver neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver
10+
11+
sudo systemctl restart neutron-server.service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
ansible -i "$LBAAS_HOSTS" all -b -K -m systemd -a "name=neutron-lbaasv2-agent state=restarted"
4+
5+
echo "Waiting for $LBAAS_HOSTS_COUNT v2 agents to be registered..."
6+
LBAASV2_HOSTS_COUNT=0
7+
8+
while [ "$LBAAS_HOSTS_COUNT" -ne "$LBAASV2_HOSTS_COUNT" ];
9+
do
10+
sleep 3
11+
LBAASV2_HOSTS_COUNT=$(mysql neutron -sNe 'select count(*) from agents where `binary` = "neutron-lbaasv2-agent"')
12+
echo "Registered $LBAASV2_HOSTS_COUNT v2 agents so far..."
13+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
sudo mysql neutron << 'EOF'
4+
# update ports device_owner
5+
update ports set device_owner = 'neutron:LOADBALANCERV2' where device_owner = 'neutron:LOADBALANCER';
6+
7+
# update lbaas_loadbalanceragentbinding (lbaas agent v1 in use)
8+
update lbaas_loadbalanceragentbindings lbab inner join agents a on (lbab.agent_id = a.id) set lbab.agent_id = IFNULL((select id from agents where `binary` = 'neutron-lbaasv2-agent' and host = a.host), lbab.agent_id);
9+
EOF
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
ansible -i "$LBAAS_HOSTS" all -b -K -m systemd -a "name=neutron-lbaasv2-agent state=restarted"
4+
5+
echo "Waiting for $LBAAS_HOSTS_COUNT v2 agents to be registered..."
6+
LBAASV2_HOSTS_COUNT=0
7+
8+
while [ "$LBAAS_HOSTS_COUNT" -ne "$LBAASV2_HOSTS_COUNT" ];
9+
do
10+
sleep 3
11+
LBAASV2_HOSTS_COUNT=$(mysql neutron -sNe 'select count(*) from agents where `binary` = "neutron-lbaasv2-agent"')
12+
echo "Registered $LBAASV2_HOSTS_COUNT v2 agents so far..."
13+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
ansible -i "$LBAAS_HOSTS" all -b -K -m script -a ansible-signal-v1-haproxy.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
sudo python ../lbaas_upgrade.py
4+
5+
sudo mysql heat << 'EOF'
6+
update raw_template set files = REPLACE(files, 'OS::Neutron::PoolMember', 'OS::Neutron::LBaaS::PoolMember');
7+
update raw_template set files = REPLACE(files, 'pool_id', 'pool');
8+
EOF
9+
10+
echo "Start heat api if everything went well!"
11+
echo "systemctl -M heat_newton start openstack-heat-api"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
uuids=$(ls /var/lib/neutron/lbaas/)
4+
uuids=$(for uuid in $uuids; do ps aux | grep -q "/[v]ar/lib/neutron/lbaas/v2/$uuid" && echo $uuid; done)
5+
pids=$(for uuid in $uuids; do ps aux | grep "/[v]ar/lib/neutron/lbaas/$uuid" | tr -s " " | cut -d " " -f 2; done);
6+
for pid in $pids; do kill -s SIGTTOU -s SIGUSR1 $pid; echo "Sending SIGTTOU & SIGUSR1 to pid $pid"; done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
uuids=$(ls /var/lib/neutron/lbaas/v2/)
4+
uuids=$(for uuid in $uuids; do ps aux | grep -q "/[v]ar/lib/neutron/lbaas/$uuid" && echo $uuid; done)
5+
pids=$(for uuid in $uuids; do ps aux | grep "/[v]ar/lib/neutron/lbaas/v2/$uuid" | tr -s " " | cut -d " " -f 2; done);
6+
for pid in $pids; do kill -s SIGTTOU -s SIGUSR1 $pid; echo "Sending SIGTTOU & SIGUSR1 to pid $pid"; done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
sudo cp -f /etc/neutron/neutron.conf.lbaasv1 /etc/neutron/neutron.conf
4+
sudo cp -f /etc/neutron/neutron_lbaas.conf.lbaasv1 /etc/neutron/neutron_lbaas.conf
5+
sudo cp -f /etc/neutron/lbaas_agent.ini.lbaasv1 /etc/neutron/lbaas_agent.ini
6+
7+
sudo systemctl disable neutron-lbaasv2-agent
8+
sudo systemctl stop neutron-lbaasv2-agent
9+
sudo systemctl enable neutron-lbaas-agent
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
sudo cp -n /etc/neutron/neutron.conf /etc/neutron/neutron.conf.lbaasv1
4+
sudo cp -n /etc/neutron/neutron_lbaas.conf /etc/neutron/neutron_lbaas.conf.lbaasv1
5+
sudo cp -n /etc/neutron/lbaas_agent.ini /etc/neutron/lbaas_agent.ini.lbaasv1
6+
7+
sudo crudini --set /etc/neutron/neutron.conf DEFAULT service_plugins router,neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2
8+
sudo crudini --set /etc/neutron/neutron_lbaas.conf service_providers service_provider LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
9+
sudo crudini --set /etc/neutron/lbaas_agent.ini DEFAULT device_driver neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver
10+
11+
sudo systemctl disable neutron-lbaas-agent
12+
sudo systemctl stop neutron-lbaas-agent
13+
sudo systemctl enable neutron-lbaasv2-agent
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
backup_dir=backup-$(hostname)
4+
cd $backup_dir
5+
6+
test -f heat.sql.gz && gunzip heat.sql.gz
7+
mysql heat < heat.sql
8+
cd -
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
test -z "$LBAAS_HOSTS" && echo "LBAAS_HOSTS env variable missing!" && exit
4+
5+
ansible -i "$LBAAS_HOSTS" all -b -K -m script -a ansible-switch-to-v1-agent.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
sudo cp -n /etc/neutron/neutron.conf.lbaasv1 /etc/neutron/neutron.conf
4+
sudo cp -n /etc/neutron/neutron_lbaas.conf.lbaasv1 /etc/neutron/neutron_lbaas.conf
5+
sudo cp -n /etc/neutron/lbaas_agent.ini.lbaasv1 /etc/neutron/lbaas_agent.ini
6+
7+
sudo systemctl restart neutron-server.service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
sudo mysql neutron << 'EOF'
4+
# update ports device_owner
5+
update ports set device_owner = 'neutron:LOADBALANCER' where device_owner = 'neutron:LOADBALANCERV2';
6+
7+
# update lbaas_loadbalanceragentbinding (lbaas agent v2 in use)
8+
update lbaas_loadbalanceragentbindings lbab inner join agents a on (lbab.agent_id = a.id) set lbab.agent_id = IFNULL((select id from agents where `binary` = 'neutron-lbaas-agent' and host = a.host), lbab.agent_id);
9+
EOF
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
ansible -i "$LBAAS_HOSTS" all -b -K -m systemd -a "name=neutron-lbaas-agent state=restarted"
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
ansible -i "$LBAAS_HOSTS" all -b -K -m script -a ansible-signal-v2-haproxy.sh

0 commit comments

Comments
 (0)