From 35a40b8511bf72de5bcec924edd19cd6e0e5a2de Mon Sep 17 00:00:00 2001 From: Saravanakumar Arumugam Date: Tue, 15 Jan 2019 11:26:23 +0100 Subject: [PATCH] Use env. variable GLUSTER_BLOCK_ENABLED to enable/disable gluster-block service. Enable gluster-block services if GLUSTER_BLOCK_ENABLED is "1" and disable otherwise. By default, GLUSTER_BLOCK_ENABLED is set as "1". When gluster-block is disabled, the status-probe.sh script should not check for its status. Updates: #120 Signed-off-by: Saravanakumar Arumugam Signed-off-by: Niels de Vos --- CentOS/Dockerfile | 2 -- CentOS/README.md | 15 +++++++++++++++ CentOS/status-probe.sh | 7 +++++-- CentOS/update-params.sh | 24 +++++++++++++++++------- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/CentOS/Dockerfile b/CentOS/Dockerfile index 81bfa27..864878d 100644 --- a/CentOS/Dockerfile +++ b/CentOS/Dockerfile @@ -94,8 +94,6 @@ systemctl disable nfs-server.service && \ systemctl mask getty.target && \ systemctl enable gluster-fake-disk.service && \ systemctl enable gluster-setup.service && \ -systemctl enable gluster-block-setup.service && \ -systemctl enable gluster-blockd.service && \ systemctl enable glusterd.service && \ systemctl enable gluster-check-diskspace.service diff --git a/CentOS/README.md b/CentOS/README.md index 9b015d0..4cae5f8 100644 --- a/CentOS/README.md +++ b/CentOS/README.md @@ -1,5 +1,20 @@ This dockerfile can be used to build a CentOS Gluster Container. +# Readiness and liveness probes + +The container contains a script at `/usr/local/bin/status-probe.sh` that can be +used to check the status of the services. The script can be called with +`readiness` or `liveness` as argument. + +# Enabling/Disabling gluster-block + +Gluster Block is an optional service that can be used to provide +PersistentVolumes of type=Block. Not everyone needs this functionality, and on +some distributions the dependencies (in the kernel) might be missing. It is +possible to disable the Gluster Block service by exporting the +`GLUSTER_BLOCK_ENABLED` environment variable set to `"0"`. By default the +environment variable will be set to `"1"` so that the service is enabled. + # Support for fake disks This container offers several configuration options that make it easier to test diff --git a/CentOS/status-probe.sh b/CentOS/status-probe.sh index 8e3b903..cae5803 100644 --- a/CentOS/status-probe.sh +++ b/CentOS/status-probe.sh @@ -3,6 +3,9 @@ # Return overall status of the glusterfs container # +: ${GLUSTER_BLOCK_ENABLED:=1} +: ${GLUSTER_BLOCKD_STATUS_PROBE_ENABLE:=1} + require() { if ! "$@" ; then echo "failed check: $*" >&2 @@ -32,8 +35,8 @@ case "$mode" in echo "warning: no mode provided. Assuming liveness probe" >&2 fi require systemctl -q is-active glusterd.service - - if [[ "$GLUSTER_BLOCKD_STATUS_PROBE_ENABLE" -eq 1 ]]; then + + if [[ "$GLUSTER_BLOCK_ENABLED" -ne 0 ]] && [[ "$GLUSTER_BLOCKD_STATUS_PROBE_ENABLE" -eq 1 ]]; then require systemctl -q is-active gluster-blockd.service fi diff --git a/CentOS/update-params.sh b/CentOS/update-params.sh index a40cc94..357cc2e 100644 --- a/CentOS/update-params.sh +++ b/CentOS/update-params.sh @@ -4,17 +4,27 @@ : ${GB_LOGDIR:=/var/log/glusterfs/gluster-block} : ${TCMU_LOGDIR:=/var/log/glusterfs/gluster-block} : ${GB_GLFS_LRU_COUNT:=15} +: ${GLUSTER_BLOCK_ENABLED:=1} : ${HOST_DEV_DIR:=/mnt/host-dev} -echo "env variable is set. Update in gluster-blockd.service" -#FIXME To update in environment file -sed -i '/GB_GLFS_LRU_COUNT=/s/GB_GLFS_LRU_COUNT=.*/'GB_GLFS_LRU_COUNT="$GB_GLFS_LRU_COUNT"\"'/' /usr/lib/systemd/system/gluster-blockd.service -sed -i '/EnvironmentFile/i Environment="GB_LOGDIR='$GB_LOGDIR'"' /usr/lib/systemd/system/gluster-blockd.service +if [ "$GLUSTER_BLOCK_ENABLED" == 1 ]; then + echo "Enabling gluster-block service and updating env. variables" + systemctl enable gluster-block-setup.service + systemctl enable gluster-blockd.service -sed -i "s#TCMU_LOGDIR=.*#TCMU_LOGDIR='$TCMU_LOGDIR'#g" /etc/sysconfig/tcmu-runner-params + #FIXME To update in environment file + sed -i '/GB_GLFS_LRU_COUNT=/s/GB_GLFS_LRU_COUNT=.*/'GB_GLFS_LRU_COUNT="$GB_GLFS_LRU_COUNT"\"'/' /usr/lib/systemd/system/gluster-blockd.service + sed -i '/EnvironmentFile/i Environment="GB_LOGDIR='$GB_LOGDIR'"' /usr/lib/systemd/system/gluster-blockd.service -sed -i '/ExecStart/i EnvironmentFile=-/etc/sysconfig/tcmu-runner-params' /usr/lib/systemd/system/tcmu-runner.service -sed -i '/tcmu-log-dir=/s/tcmu-log-dir.*/tcmu-log-dir $TCMU_LOGDIR/' /usr/lib/systemd/system/tcmu-runner.service + sed -i "s#TCMU_LOGDIR=.*#TCMU_LOGDIR='$TCMU_LOGDIR'#g" /etc/sysconfig/tcmu-runner-params + + sed -i '/ExecStart/i EnvironmentFile=-/etc/sysconfig/tcmu-runner-params' /usr/lib/systemd/system/tcmu-runner.service + sed -i '/tcmu-log-dir=/s/tcmu-log-dir.*/tcmu-log-dir $TCMU_LOGDIR/' /usr/lib/systemd/system/tcmu-runner.service +else + echo "Disabling gluster-block service" + systemctl disable gluster-block-setup.service + systemctl disable gluster-blockd.service +fi if [ -c "${HOST_DEV_DIR}/zero" ] && [ -c "${HOST_DEV_DIR}/null" ]; then # looks like an alternate "host dev" has been provided