From 6fa0fa5cd94eb970fba801810d307acdb2d42e3d Mon Sep 17 00:00:00 2001 From: Pranav Salunke Date: Tue, 21 Apr 2015 15:57:00 +0200 Subject: [PATCH] Fix apache2 error Apache2 service was not restarting properly since Ubuntu14.04 which resulted in race conditions. This is explained in detail in the script. Adds a work around to fix apache2 race invoked by lack of www-browser virtual package linking to a basic text browser. Adding w3m before hand to avoid any future issues. Ofcourse lynx or links works here too. Also provides more systematic stopping and starting of apache service for eliminating restart/start-stop race issues. Change-Id: I541d5b27bbfdda9b9f3eda72a0f13e9e8333faa2 --- labs/scripts/setup_lbaas_controller.sh | 19 ++++++++++++++++++- labs/scripts/ubuntu/apt_init.sh | 11 +++++++++++ labs/scripts/ubuntu/setup_horizon.sh | 18 +++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/labs/scripts/setup_lbaas_controller.sh b/labs/scripts/setup_lbaas_controller.sh index c0629c8a..4ebdbc90 100755 --- a/labs/scripts/setup_lbaas_controller.sh +++ b/labs/scripts/setup_lbaas_controller.sh @@ -36,6 +36,23 @@ function check_dashboard_settings { echo "Checking dashboard configuration." check_dashboard_settings +function check_apache_service { + # Check if apache service is down, if not force retry a couple of times. + sleep 10 + i=0 + until service apache2 status | grep 'not running'; do + sudo service apache2 stop + sleep 10 + i ++ + if [ $i -gt 3 ] + then + break + fi + done +} + echo "Reloading apache and memcached service." -sudo service apache2 restart +sudo service apache2 stop +check_apache_service +sudo service apache2 start sudo service memcached restart diff --git a/labs/scripts/ubuntu/apt_init.sh b/labs/scripts/ubuntu/apt_init.sh index 96605951..17861af8 100755 --- a/labs/scripts/ubuntu/apt_init.sh +++ b/labs/scripts/ubuntu/apt_init.sh @@ -50,9 +50,20 @@ function ubuntu_cloud_archive { -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" } +function apache_fix { + + # On '$service apache2 restart', apache will use a text browser to check + # connectivity on '127.0.0.1' or 'localhost'. Apache needs www-browser + # (/etc/alternatives/www-browser) virtual package to carry out this check. + # Include a basic text browser to preemptively avoid this error. + sudo apt-get -y install w3m + +} + # precise needs the cloud archive, and so does trusty for non-Icehouse releases if grep -qs DISTRIB_CODENAME=precise /etc/lsb-release || [ "$OPENSTACK_RELEASE" != "icehouse" ]; then echo "Enabling the Ubuntu cloud archive." ubuntu_cloud_archive + apache_fix fi diff --git a/labs/scripts/ubuntu/setup_horizon.sh b/labs/scripts/ubuntu/setup_horizon.sh index 2ba1cfe8..ffc1c37e 100755 --- a/labs/scripts/ubuntu/setup_horizon.sh +++ b/labs/scripts/ubuntu/setup_horizon.sh @@ -53,6 +53,22 @@ function check_dashboard_settings { echo "Checking dashboard configuration." check_dashboard_settings +function check_apache_service { + # Check if apache service is down, if not force retry a couple of times. + sleep 10 + i=0 + until service apache2 status | grep 'not running'; do + sudo service apache2 stop + sleep 10 + i ++ + if [ $i -gt 3] + then + break + fi + done +} + echo "Reloading apache and memcached service." -sudo service apache2 restart +sudo service apache2 stop +check_apache_service sudo service memcached restart