Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
the Azure Data Lake Storage ([#853]).
- kafka: Add cyrus-sasl-gssapi package for kerberos ([#874]).
- spark: Add HBase connector ([#878], [#882]).
- hbase: hbase-entrypoint.sh script to start and gracefully stop services ([#898]).

### Changed

Expand Down Expand Up @@ -85,6 +86,7 @@ All notable changes to this project will be documented in this file.
[#890]: https://github.com/stackabletech/docker-images/pull/890
[#894]: https://github.com/stackabletech/docker-images/pull/894
[#896]: https://github.com/stackabletech/docker-images/pull/896
[#898]: https://github.com/stackabletech/docker-images/pull/898

## [24.7.0] - 2024-07-24

Expand Down
3 changes: 2 additions & 1 deletion hbase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-builder /stackable/jmx /stacka

COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS} /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/
COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/bin/hbck2 /stackable/bin/hbck2
COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/bin/hbase-entrypoint.sh /stackable/hbase-${PRODUCT}/bin/hbase-entrypoint.sh

COPY --chown=${STACKABLE_USER_UID}:0 --from=phoenix-builder /stackable/phoenix /stackable/phoenix/

Expand Down Expand Up @@ -367,4 +368,4 @@ ENV PATH="${PATH}:/stackable/bin:/stackable/hbase/bin"
ENV ASYNC_PROFILER_HOME=/stackable/async-profiler

WORKDIR /stackable/hbase
CMD ["./bin/hbase", "master", "start" ]
CMD ["./bin/hbase-entrypoint", "master", "localhost", "16010" ]
72 changes: 72 additions & 0 deletions hbase/stackable/bin/hbase-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
#
# Entrypoint for HBase that ensures services are shutdown gracefuly
#
set -x
set -euo pipefail

# master, regionserver, rest
HBASE_ROLE_NAME="$1"
# k8s service name for this role+group combo
# <svc-name>.<namespace>.svc.cluster.local
HBASE_ROLE_SERVICE_NAME="$2"
# 16010 for master, 16020 for regionservers etc.
HBASE_ROLE_SERVICE_PORT="$3"

HBASE_ROLE_SERVICE_HOST="${HOSTNAME}.${HBASE_ROLE_SERVICE_NAME}"

REGION_MOVER_OPTS="--regionserverhost ${HBASE_ROLE_SERVICE_HOST}:${HBASE_ROLE_SERVICE_PORT} --operation unload ${REGION_MOVER_OPTS}"

if [ -f /stackable/kerberos/krb5.conf ]; then
KERBEROS_REALM=$(grep -oP 'default_realm = \\K.*' /stackable/kerberos/krb5.conf)
export KERBEROS_REALM
fi

prepare_signal_handlers() {
unset term_child_pid
unset term_kill_needed
trap handle_term_signal TERM
}

handle_term_signal() {
if [ "${term_child_pid}" ]; then
if [ "regionserver" == "${HBASE_ROLE_NAME}" ]; then
echo "Start pre-shutdown"
# REGION_MOVER_OPTS is a string that contains multiple arguments and needs to be spliced here
# therefore disable shellcheck for this line
# shellcheck disable=SC2086
/stackable/hbase/bin/hbase org.apache.hadoop.hbase.util.RegionMover ${REGION_MOVER_OPTS}
echo "Done pre-shutdown"
fi
kill -TERM "${term_child_pid}" 2>/dev/null
else
term_kill_needed='yes'
fi
}

wait_for_termination() {
set +e
term_child_pid=$1
if [[ -v term_kill_needed ]]; then
kill -TERM "${term_child_pid}" 2>/dev/null
fi
wait "${term_child_pid}" 2>/dev/null
trap - TERM
wait "${term_child_pid}" 2>/dev/null
set -e
}

# ##################################################################################################
# main
# ##################################################################################################
mkdir -p /stackable/conf
cp /stackable/tmp/hdfs/hdfs-site.xml /stackable/conf
cp /stackable/tmp/hdfs/core-site.xml /stackable/conf
cp /stackable/tmp/hbase/* /stackable/conf
cp /stackable/tmp/log_config/log4j* /stackable/conf

rm -f /stackable/log/_vector/shutdown
prepare_signal_handlers
/stackable/hbase/bin/hbase "${HBASE_ROLE_NAME}" start &
wait_for_termination $!
mkdir -p /stackable/log/_vector && touch /stackable/log/_vector/shutdown
Loading