This attempts to make the zookeeper installation a bit more modular
(assuming that other folks will want to add other dlms as plugins),
and addresses the service start issues with zookeeper under
ubuntu/upstart.
Zookeeper is not going to be installed by default. Services need to
ask for it with use_dlm.
Change-Id: I33525e2b83a4497a57ec95f62880e0308c88b34f
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,108 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# |
|
| 2 |
+# lib/dlm |
|
| 3 |
+# |
|
| 4 |
+# Functions to control the installation and configuration of software |
|
| 5 |
+# that provides a dlm (and possibly other functions). The default is |
|
| 6 |
+# **zookeeper**, and is going to be the only backend supported in the |
|
| 7 |
+# devstack tree. |
|
| 8 |
+ |
|
| 9 |
+# Dependencies: |
|
| 10 |
+# |
|
| 11 |
+# - ``functions`` file |
|
| 12 |
+ |
|
| 13 |
+# ``stack.sh`` calls the entry points in this order: |
|
| 14 |
+# |
|
| 15 |
+# - is_dlm_enabled |
|
| 16 |
+# - install_dlm |
|
| 17 |
+# - configure_dlm |
|
| 18 |
+# - cleanup_dlm |
|
| 19 |
+ |
|
| 20 |
+# Save trace setting |
|
| 21 |
+XTRACE=$(set +o | grep xtrace) |
|
| 22 |
+set +o xtrace |
|
| 23 |
+ |
|
| 24 |
+ |
|
| 25 |
+# Defaults |
|
| 26 |
+# -------- |
|
| 27 |
+ |
|
| 28 |
+# <define global variables here that belong to this project> |
|
| 29 |
+ |
|
| 30 |
+# Set up default directories |
|
| 31 |
+ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper |
|
| 32 |
+ZOOKEEPER_CONF_DIR=/etc/zookeeper |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 35 |
+# Entry Points |
|
| 36 |
+# ------------ |
|
| 37 |
+# |
|
| 38 |
+# NOTE(sdague): it is expected that when someone wants to implement |
|
| 39 |
+# another one of these out of tree, they'll implement the following |
|
| 40 |
+# functions: |
|
| 41 |
+# |
|
| 42 |
+# - dlm_backend |
|
| 43 |
+# - install_dlm |
|
| 44 |
+# - configure_dlm |
|
| 45 |
+# - cleanup_dlm |
|
| 46 |
+ |
|
| 47 |
+# This should be declared in the settings file of any plugin or |
|
| 48 |
+# service that needs to have a dlm in their enviroment. |
|
| 49 |
+function use_dlm {
|
|
| 50 |
+ enable_service $(dlm_backend) |
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+# A function to return the name of the backend in question, some users |
|
| 54 |
+# are going to need to know this. |
|
| 55 |
+function dlm_backend {
|
|
| 56 |
+ echo "zookeeper" |
|
| 57 |
+} |
|
| 58 |
+ |
|
| 59 |
+# Test if a dlm is enabled (defaults to a zookeeper specific check) |
|
| 60 |
+function is_dlm_enabled {
|
|
| 61 |
+ [[ ,${ENABLED_SERVICES}, =~ ,"$(dlm_backend)", ]] && return 0
|
|
| 62 |
+ return 1 |
|
| 63 |
+} |
|
| 64 |
+ |
|
| 65 |
+# cleanup_dlm() - Remove residual data files, anything left over from previous |
|
| 66 |
+# runs that a clean run would need to clean up |
|
| 67 |
+function cleanup_dlm {
|
|
| 68 |
+ # NOTE(sdague): we don't check for is_enabled here because we |
|
| 69 |
+ # should just delete this regardless. Some times users updated |
|
| 70 |
+ # their service list before they run cleanup. |
|
| 71 |
+ sudo rm -rf $ZOOKEEPER_DATA_DIR |
|
| 72 |
+} |
|
| 73 |
+ |
|
| 74 |
+# configure_dlm() - Set config files, create data dirs, etc |
|
| 75 |
+function configure_dlm {
|
|
| 76 |
+ if is_dlm_enabled; then |
|
| 77 |
+ sudo cp $FILES/zookeeper/* $ZOOKEEPER_CONF_DIR |
|
| 78 |
+ sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg |
|
| 79 |
+ # clean up from previous (possibly aborted) runs |
|
| 80 |
+ # create required data files |
|
| 81 |
+ sudo rm -rf $ZOOKEEPER_DATA_DIR |
|
| 82 |
+ sudo mkdir -p $ZOOKEEPER_DATA_DIR |
|
| 83 |
+ # restart after configuration, there is no reason to make this |
|
| 84 |
+ # another step, because having data files that don't match the |
|
| 85 |
+ # zookeeper running is just going to cause tears. |
|
| 86 |
+ restart_service zookeeper |
|
| 87 |
+ fi |
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+# install_dlm() - Collect source and prepare |
|
| 91 |
+function install_dlm {
|
|
| 92 |
+ if is_dlm_enabled; then |
|
| 93 |
+ if is_ubuntu; then |
|
| 94 |
+ install_package zookeeperd |
|
| 95 |
+ else |
|
| 96 |
+ die $LINENO "Don't know how to install zookeeper on this platform" |
|
| 97 |
+ fi |
|
| 98 |
+ fi |
|
| 99 |
+} |
|
| 100 |
+ |
|
| 101 |
+# Restore xtrace |
|
| 102 |
+$XTRACE |
|
| 103 |
+ |
|
| 104 |
+# Tell emacs to use shell-script-mode |
|
| 105 |
+## Local variables: |
|
| 106 |
+## mode: shell-script |
|
| 107 |
+## End: |
| 0 | 108 |
deleted file mode 100644 |
| ... | ... |
@@ -1,91 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-# |
|
| 3 |
-# lib/zookeeper |
|
| 4 |
-# Functions to control the installation and configuration of **zookeeper** |
|
| 5 |
- |
|
| 6 |
-# Dependencies: |
|
| 7 |
-# |
|
| 8 |
-# - ``functions`` file |
|
| 9 |
- |
|
| 10 |
-# ``stack.sh`` calls the entry points in this order: |
|
| 11 |
-# |
|
| 12 |
-# - is_zookeeper_enabled |
|
| 13 |
-# - install_zookeeper |
|
| 14 |
-# - configure_zookeeper |
|
| 15 |
-# - init_zookeeper |
|
| 16 |
-# - start_zookeeper |
|
| 17 |
-# - stop_zookeeper |
|
| 18 |
-# - cleanup_zookeeper |
|
| 19 |
- |
|
| 20 |
-# Save trace setting |
|
| 21 |
-XTRACE=$(set +o | grep xtrace) |
|
| 22 |
-set +o xtrace |
|
| 23 |
- |
|
| 24 |
- |
|
| 25 |
-# Defaults |
|
| 26 |
-# -------- |
|
| 27 |
- |
|
| 28 |
-# <define global variables here that belong to this project> |
|
| 29 |
- |
|
| 30 |
-# Set up default directories |
|
| 31 |
-ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper |
|
| 32 |
-ZOOKEEPER_CONF_DIR=/etc/zookeeper |
|
| 33 |
- |
|
| 34 |
- |
|
| 35 |
-# Entry Points |
|
| 36 |
-# ------------ |
|
| 37 |
- |
|
| 38 |
-# Test if any zookeeper service us enabled |
|
| 39 |
-# is_zookeeper_enabled |
|
| 40 |
-function is_zookeeper_enabled {
|
|
| 41 |
- [[ ,${ENABLED_SERVICES}, =~ ,"zookeeper", ]] && return 0
|
|
| 42 |
- return 1 |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-# cleanup_zookeeper() - Remove residual data files, anything left over from previous |
|
| 46 |
-# runs that a clean run would need to clean up |
|
| 47 |
-function cleanup_zookeeper {
|
|
| 48 |
- sudo rm -rf $ZOOKEEPER_DATA_DIR |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-# configure_zookeeper() - Set config files, create data dirs, etc |
|
| 52 |
-function configure_zookeeper {
|
|
| 53 |
- sudo cp $FILES/zookeeper/* $ZOOKEEPER_CONF_DIR |
|
| 54 |
- sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg |
|
| 55 |
-} |
|
| 56 |
- |
|
| 57 |
-# init_zookeeper() - Initialize databases, etc. |
|
| 58 |
-function init_zookeeper {
|
|
| 59 |
- # clean up from previous (possibly aborted) runs |
|
| 60 |
- # create required data files |
|
| 61 |
- sudo rm -rf $ZOOKEEPER_DATA_DIR |
|
| 62 |
- sudo mkdir -p $ZOOKEEPER_DATA_DIR |
|
| 63 |
-} |
|
| 64 |
- |
|
| 65 |
-# install_zookeeper() - Collect source and prepare |
|
| 66 |
-function install_zookeeper {
|
|
| 67 |
- install_package zookeeperd |
|
| 68 |
-} |
|
| 69 |
- |
|
| 70 |
-# start_zookeeper() - Start running processes, including screen |
|
| 71 |
-function start_zookeeper {
|
|
| 72 |
- # Starting twice Zookeeper on Ubuntu exits with error code 1. See LP#1513741 |
|
| 73 |
- # Match both systemd and sysvinit output |
|
| 74 |
- local running="(active \(running\)|start/running)" |
|
| 75 |
- if ! is_ubuntu || ! sudo /usr/sbin/service zookeeper status | egrep -q "$running"; then |
|
| 76 |
- start_service zookeeper |
|
| 77 |
- fi |
|
| 78 |
-} |
|
| 79 |
- |
|
| 80 |
-# stop_zookeeper() - Stop running processes (non-screen) |
|
| 81 |
-function stop_zookeeper {
|
|
| 82 |
- stop_service zookeeper |
|
| 83 |
-} |
|
| 84 |
- |
|
| 85 |
-# Restore xtrace |
|
| 86 |
-$XTRACE |
|
| 87 |
- |
|
| 88 |
-# Tell emacs to use shell-script-mode |
|
| 89 |
-## Local variables: |
|
| 90 |
-## mode: shell-script |
|
| 91 |
-## End: |
| ... | ... |
@@ -539,7 +539,7 @@ source $TOP_DIR/lib/heat |
| 539 | 539 |
source $TOP_DIR/lib/neutron-legacy |
| 540 | 540 |
source $TOP_DIR/lib/ldap |
| 541 | 541 |
source $TOP_DIR/lib/dstat |
| 542 |
-source $TOP_DIR/lib/zookeeper |
|
| 542 |
+source $TOP_DIR/lib/dlm |
|
| 543 | 543 |
|
| 544 | 544 |
# Extras Source |
| 545 | 545 |
# -------------- |
| ... | ... |
@@ -724,11 +724,10 @@ run_phase stack pre-install |
| 724 | 724 |
|
| 725 | 725 |
install_rpc_backend |
| 726 | 726 |
|
| 727 |
-if is_service_enabled zookeeper; then |
|
| 728 |
- cleanup_zookeeper |
|
| 729 |
- configure_zookeeper |
|
| 730 |
- init_zookeeper |
|
| 731 |
-fi |
|
| 727 |
+# NOTE(sdague): dlm install is conditional on one being enabled by configuration |
|
| 728 |
+install_dlm |
|
| 729 |
+configure_dlm |
|
| 730 |
+ |
|
| 732 | 731 |
if is_service_enabled $DATABASE_BACKENDS; then |
| 733 | 732 |
install_database |
| 734 | 733 |
fi |
| ... | ... |
@@ -968,15 +967,6 @@ save_stackenv $LINENO |
| 968 | 968 |
start_dstat |
| 969 | 969 |
|
| 970 | 970 |
|
| 971 |
-# Zookeeper |
|
| 972 |
-# ----- |
|
| 973 |
- |
|
| 974 |
-# zookeeper for use with tooz for Distributed Lock Management capabilities etc., |
|
| 975 |
-if is_service_enabled zookeeper; then |
|
| 976 |
- start_zookeeper |
|
| 977 |
-fi |
|
| 978 |
- |
|
| 979 |
- |
|
| 980 | 971 |
# Keystone |
| 981 | 972 |
# -------- |
| 982 | 973 |
|
| ... | ... |
@@ -69,7 +69,7 @@ if ! isset ENABLED_SERVICES ; then |
| 69 | 69 |
# Dashboard |
| 70 | 70 |
ENABLED_SERVICES+=,horizon |
| 71 | 71 |
# Additional services |
| 72 |
- ENABLED_SERVICES+=,rabbit,tempest,mysql,dstat,zookeeper |
|
| 72 |
+ ENABLED_SERVICES+=,rabbit,tempest,mysql,dstat |
|
| 73 | 73 |
fi |
| 74 | 74 |
|
| 75 | 75 |
# SQLAlchemy supports multiple database drivers for each database server |