Back port these commits to stable/havana:
* https://github.com/openstack-dev/devstack/commit/9fc8792b0ac7525b4c353b0a55b8b80eabf76e2a
https://review.openstack.org/66080
* https://github.com/openstack-dev/devstack/commit/579af5d6786f62008807a473749600e88cea21fc
https://review.openstack.org/68699
Change-Id: I860cb27a33a4147765b75f0b130782cbc19af9ce
| ... | ... |
@@ -1112,10 +1112,42 @@ function screen_it {
|
| 1112 | 1112 |
sleep 1.5 |
| 1113 | 1113 |
|
| 1114 | 1114 |
NL=`echo -ne '\015'` |
| 1115 |
- screen -S $SCREEN_NAME -p $1 -X stuff "$2 || echo \"$1 failed to start\" | tee \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL" |
|
| 1115 |
+ # This fun command does the following: |
|
| 1116 |
+ # - the passed server command is backgrounded |
|
| 1117 |
+ # - the pid of the background process is saved in the usual place |
|
| 1118 |
+ # - the server process is brought back to the foreground |
|
| 1119 |
+ # - if the server process exits prematurely the fg command errors |
|
| 1120 |
+ # and a message is written to stdout and the service failure file |
|
| 1121 |
+ # The pid saved can be used in screen_stop() as a process group |
|
| 1122 |
+ # id to kill off all child processes |
|
| 1123 |
+ screen -S $SCREEN_NAME -p $1 -X stuff "$2 & echo \$! >$SERVICE_DIR/$SCREEN_NAME/$1.pid; fg || echo \"$1 failed to start\" | tee \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL" |
|
| 1116 | 1124 |
else |
| 1117 | 1125 |
# Spawn directly without screen |
| 1118 |
- run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$service.pid |
|
| 1126 |
+ run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$1.pid |
|
| 1127 |
+ fi |
|
| 1128 |
+ fi |
|
| 1129 |
+} |
|
| 1130 |
+ |
|
| 1131 |
+ |
|
| 1132 |
+# Stop a service in screen |
|
| 1133 |
+# If a PID is available use it, kill the whole process group via TERM |
|
| 1134 |
+# If screen is being used kill the screen window; this will catch processes |
|
| 1135 |
+# that did not leave a PID behind |
|
| 1136 |
+# screen_stop service |
|
| 1137 |
+function screen_stop() {
|
|
| 1138 |
+ SCREEN_NAME=${SCREEN_NAME:-stack}
|
|
| 1139 |
+ SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
|
|
| 1140 |
+ USE_SCREEN=$(trueorfalse True $USE_SCREEN) |
|
| 1141 |
+ |
|
| 1142 |
+ if is_service_enabled $1; then |
|
| 1143 |
+ # Kill via pid if we have one available |
|
| 1144 |
+ if [[ -r $SERVICE_DIR/$SCREEN_NAME/$1.pid ]]; then |
|
| 1145 |
+ pkill -TERM -P -$(cat $SERVICE_DIR/$SCREEN_NAME/$1.pid) |
|
| 1146 |
+ rm $SERVICE_DIR/$SCREEN_NAME/$1.pid |
|
| 1147 |
+ fi |
|
| 1148 |
+ if [[ "$USE_SCREEN" = "True" ]]; then |
|
| 1149 |
+ # Clean up the screen window |
|
| 1150 |
+ screen -S $SCREEN_NAME -p $1 -X kill |
|
| 1119 | 1151 |
fi |
| 1120 | 1152 |
fi |
| 1121 | 1153 |
} |
| ... | ... |
@@ -146,7 +146,7 @@ function start_ceilometer() {
|
| 146 | 146 |
function stop_ceilometer() {
|
| 147 | 147 |
# Kill the ceilometer screen windows |
| 148 | 148 |
for serv in ceilometer-acompute ceilometer-acentral ceilometer-collector ceilometer-api ceilometer-alarm-notifier ceilometer-alarm-evaluator; do |
| 149 |
- screen -S $SCREEN_NAME -p $serv -X kill |
|
| 149 |
+ screen_stop $serv |
|
| 150 | 150 |
done |
| 151 | 151 |
} |
| 152 | 152 |
|
| ... | ... |
@@ -530,7 +530,7 @@ function start_cinder() {
|
| 530 | 530 |
function stop_cinder() {
|
| 531 | 531 |
# Kill the cinder screen windows |
| 532 | 532 |
for serv in c-api c-bak c-sch c-vol; do |
| 533 |
- screen -S $SCREEN_NAME -p $serv -X kill |
|
| 533 |
+ screen_stop $serv |
|
| 534 | 534 |
done |
| 535 | 535 |
|
| 536 | 536 |
if is_service_enabled c-vol; then |
| ... | ... |
@@ -201,8 +201,8 @@ function start_glance() {
|
| 201 | 201 |
# stop_glance() - Stop running processes |
| 202 | 202 |
function stop_glance() {
|
| 203 | 203 |
# Kill the Glance screen windows |
| 204 |
- screen -S $SCREEN_NAME -p g-api -X kill |
|
| 205 |
- screen -S $SCREEN_NAME -p g-reg -X kill |
|
| 204 |
+ screen_stop g-api |
|
| 205 |
+ screen_stop g-reg |
|
| 206 | 206 |
} |
| 207 | 207 |
|
| 208 | 208 |
|
| ... | ... |
@@ -666,7 +666,7 @@ function stop_nova() {
|
| 666 | 666 |
# Some services are listed here twice since more than one instance |
| 667 | 667 |
# of a service may be running in certain configs. |
| 668 | 668 |
for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n-cond n-cell n-cell n-api-meta; do |
| 669 |
- screen -S $SCREEN_NAME -p $serv -X kill |
|
| 669 |
+ screen_stop $serv |
|
| 670 | 670 |
done |
| 671 | 671 |
if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then |
| 672 | 672 |
stop_nova_hypervisor |
| ... | ... |
@@ -36,6 +36,9 @@ source $TOP_DIR/lib/apache |
| 36 | 36 |
# Get project function libraries |
| 37 | 37 |
source $TOP_DIR/lib/baremetal |
| 38 | 38 |
source $TOP_DIR/lib/cinder |
| 39 |
+source $TOP_DIR/lib/keystone |
|
| 40 |
+source $TOP_DIR/lib/glance |
|
| 41 |
+source $TOP_DIR/lib/nova |
|
| 39 | 42 |
source $TOP_DIR/lib/horizon |
| 40 | 43 |
source $TOP_DIR/lib/swift |
| 41 | 44 |
source $TOP_DIR/lib/neutron |
| ... | ... |
@@ -75,21 +78,29 @@ if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then |
| 75 | 75 |
teardown_neutron_debug |
| 76 | 76 |
fi |
| 77 | 77 |
|
| 78 |
-# Shut down devstack's screen to get the bulk of OpenStack services in one shot |
|
| 79 |
-SCREEN=$(which screen) |
|
| 80 |
-if [[ -n "$SCREEN" ]]; then |
|
| 81 |
- SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
|
|
| 82 |
- if [[ -n "$SESSION" ]]; then |
|
| 83 |
- screen -X -S $SESSION quit |
|
| 84 |
- fi |
|
| 78 |
+# Call service stop |
|
| 79 |
+if is_service_enabled trove; then |
|
| 80 |
+ stop_trove |
|
| 81 |
+fi |
|
| 82 |
+ |
|
| 83 |
+if is_service_enabled heat; then |
|
| 84 |
+ stop_heat |
|
| 85 | 85 |
fi |
| 86 | 86 |
|
| 87 |
-# Shut down Nova hypervisor plugins after Nova |
|
| 88 |
-NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins |
|
| 89 |
-if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then |
|
| 90 |
- # Load plugin |
|
| 91 |
- source $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER |
|
| 92 |
- stop_nova_hypervisor |
|
| 87 |
+if is_service_enabled ceilometer; then |
|
| 88 |
+ stop_ceilometer |
|
| 89 |
+fi |
|
| 90 |
+ |
|
| 91 |
+if is_service_enabled nova; then |
|
| 92 |
+ stop_nova |
|
| 93 |
+fi |
|
| 94 |
+ |
|
| 95 |
+if is_service_enabled g-api g-reg; then |
|
| 96 |
+ stop_glance |
|
| 97 |
+fi |
|
| 98 |
+ |
|
| 99 |
+if is_service_enabled key; then |
|
| 100 |
+ stop_keystone |
|
| 93 | 101 |
fi |
| 94 | 102 |
|
| 95 | 103 |
# Swift runs daemons |
| ... | ... |
@@ -123,6 +134,7 @@ SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* |
| 123 | 123 |
|
| 124 | 124 |
# Get the iSCSI volumes |
| 125 | 125 |
if is_service_enabled cinder; then |
| 126 |
+ stop_cinder |
|
| 126 | 127 |
cleanup_cinder |
| 127 | 128 |
fi |
| 128 | 129 |
|
| ... | ... |
@@ -152,4 +164,13 @@ if is_service_enabled trove; then |
| 152 | 152 |
cleanup_trove |
| 153 | 153 |
fi |
| 154 | 154 |
|
| 155 |
+# Clean up the remainder of the screen processes |
|
| 156 |
+SCREEN=$(which screen) |
|
| 157 |
+if [[ -n "$SCREEN" ]]; then |
|
| 158 |
+ SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
|
|
| 159 |
+ if [[ -n "$SESSION" ]]; then |
|
| 160 |
+ screen -X -S $SESSION quit |
|
| 161 |
+ fi |
|
| 162 |
+fi |
|
| 163 |
+ |
|
| 155 | 164 |
cleanup_tmp |