From 0b3bdc6f6647ff4418b70d4452238a2f7ecfda1c Mon Sep 17 00:00:00 2001 From: Andrei Suciu Date: Fri, 20 May 2022 15:31:19 +0300 Subject: [PATCH] Debian: replace ceph workarounds Description: - replace library path - change call for getting stack trace - update ownership for /var/lib/ceph - remove ceph user creation -Test Plan: PASSED: build packages and image /Debian PASSED: bootstrap and unlock /Debian PASSED: checked for failed processes /Debian PASSED: check system application-list /Debian PASSED: checked for ceph alarms /Debian PASSED: checked ceph status, puppet logs /Debian PASSED: checked ceph and system application-list status after unlock /CentOS Story: 2009965 Task: 45438 Change-Id: If864d288e5b63928f18a5b31551b4cd479b00fe8 --- .../debian/deb_folder/ceph-base.ceph.init | 2 +- .../ceph/debian/deb_folder/ceph-base.postinst | 4 +-- .../debian/deb_folder/ceph-common.postinst | 35 +++---------------- .../ceph/debian/deb_folder/ceph-common.postrm | 8 ----- ceph/ceph/debian/deb_folder/ceph-mds.postinst | 4 +-- ceph/ceph/debian/deb_folder/ceph-mgr.postinst | 4 +-- ceph/ceph/debian/deb_folder/radosgw.postinst | 4 +-- ceph/ceph/files/ceph-init-wrapper.sh | 12 +++++-- 8 files changed, 23 insertions(+), 50 deletions(-) diff --git a/ceph/ceph/debian/deb_folder/ceph-base.ceph.init b/ceph/ceph/debian/deb_folder/ceph-base.ceph.init index 92dbd4b2c..80bb233b9 100755 --- a/ceph/ceph/debian/deb_folder/ceph-base.ceph.init +++ b/ceph/ceph/debian/deb_folder/ceph-base.ceph.init @@ -36,7 +36,7 @@ else else BINDIR=/usr/bin SBINDIR=/usr/sbin - LIBDIR=/usr/lib64/ceph + LIBDIR=/usr/lib/ceph LIBEXECDIR=$LIBDIR ETCDIR=/etc/ceph ASSUME_DEV=0 diff --git a/ceph/ceph/debian/deb_folder/ceph-base.postinst b/ceph/ceph/debian/deb_folder/ceph-base.postinst index 23712a8b4..ac20911df 100644 --- a/ceph/ceph/debian/deb_folder/ceph-base.postinst +++ b/ceph/ceph/debian/deb_folder/ceph-base.postinst @@ -25,8 +25,8 @@ set -e # the debian-policy package [ -f "/etc/default/ceph" ] && . /etc/default/ceph -[ -z "$SERVER_USER" ] && SERVER_USER=ceph -[ -z "$SERVER_GROUP" ] && SERVER_GROUP=ceph +[ -z "$SERVER_USER" ] && SERVER_USER=root +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=root case "$1" in configure) diff --git a/ceph/ceph/debian/deb_folder/ceph-common.postinst b/ceph/ceph/debian/deb_folder/ceph-common.postinst index 5535e9dee..802640806 100644 --- a/ceph/ceph/debian/deb_folder/ceph-common.postinst +++ b/ceph/ceph/debian/deb_folder/ceph-common.postinst @@ -24,9 +24,9 @@ set -e [ -f "/etc/default/ceph" ] && . /etc/default/ceph [ -z "$SERVER_HOME" ] && SERVER_HOME=/var/lib/ceph -[ -z "$SERVER_USER" ] && SERVER_USER=ceph +[ -z "$SERVER_USER" ] && SERVER_USER=root [ -z "$SERVER_NAME" ] && SERVER_NAME="Ceph storage service" -[ -z "$SERVER_GROUP" ] && SERVER_GROUP=ceph +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=root [ -z "$SERVER_UID" ] && SERVER_UID=64045 # alloc by Debian base-passwd maintainer [ -z "$SERVER_GID" ] && SERVER_GID=$SERVER_UID @@ -51,33 +51,6 @@ finish_mv_ceph_defaults() { case "$1" in configure) # create user to avoid running server as root - # 1. create group if not existing - if ! getent group | grep -q "^$SERVER_GROUP:" ; then - echo -n "Adding group $SERVER_GROUP.." - addgroup --quiet --system --gid $SERVER_GID \ - $SERVER_GROUP 2>/dev/null ||true - echo "..done" - fi - # 2. create user if not existing - if ! getent passwd | grep -q "^$SERVER_USER:"; then - echo -n "Adding system user $SERVER_USER.." - adduser --quiet \ - --system \ - --no-create-home \ - --disabled-password \ - --uid $SERVER_UID \ - --gid $SERVER_GID \ - --home $SERVER_HOME \ - $SERVER_USER 2>/dev/null || true - echo "..done" - fi - # 3. adjust passwd entry - echo -n "Setting system user $SERVER_USER properties.." - usermod -c "$SERVER_NAME" \ - -d $SERVER_HOME \ - -g $SERVER_GROUP \ - $SERVER_USER - # Unlock $SERVER_USER in case it is locked from an uninstall if [ -f /etc/shadow ]; then usermod -U -e '' $SERVER_USER @@ -86,7 +59,7 @@ case "$1" in fi echo "..done" - # 5. adjust file and directory permissions + # adjust file and directory permissions if ! dpkg-statoverride --list $SERVER_HOME >/dev/null then chown $SERVER_USER:$SERVER_GROUP $SERVER_HOME @@ -100,7 +73,7 @@ case "$1" in chmod u=rwx,g=rwxs,o=t /var/log/ceph fi - # 6. fix /var/run/ceph + # fix /var/run/ceph if [ -d /var/run/ceph ]; then echo -n "Fixing /var/run/ceph ownership.." chown $SERVER_USER:$SERVER_GROUP /var/run/ceph diff --git a/ceph/ceph/debian/deb_folder/ceph-common.postrm b/ceph/ceph/debian/deb_folder/ceph-common.postrm index e4051180d..f97870285 100644 --- a/ceph/ceph/debian/deb_folder/ceph-common.postrm +++ b/ceph/ceph/debian/deb_folder/ceph-common.postrm @@ -35,17 +35,9 @@ case "$1" in purge) [ -f "/etc/default/ceph" ] && . /etc/default/ceph - [ -z "$SERVER_USER" ] && SERVER_USER=ceph - rm -rf /var/log/ceph rm -rf /etc/ceph - if [ -f /etc/shadow ]; then - usermod -L -e 1 $SERVER_USER - else - usermod -L $SERVER_USER - fi - ;; abort-install|abort-upgrade) diff --git a/ceph/ceph/debian/deb_folder/ceph-mds.postinst b/ceph/ceph/debian/deb_folder/ceph-mds.postinst index 3ae908a99..f8c3c1269 100644 --- a/ceph/ceph/debian/deb_folder/ceph-mds.postinst +++ b/ceph/ceph/debian/deb_folder/ceph-mds.postinst @@ -19,8 +19,8 @@ set -e # the debian-policy package [ -f "/etc/default/ceph" ] && . /etc/default/ceph -[ -z "$SERVER_USER" ] && SERVER_USER=ceph -[ -z "$SERVER_GROUP" ] && SERVER_GROUP=ceph +[ -z "$SERVER_USER" ] && SERVER_USER=root +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=root case "$1" in configure) diff --git a/ceph/ceph/debian/deb_folder/ceph-mgr.postinst b/ceph/ceph/debian/deb_folder/ceph-mgr.postinst index 6d38ccf09..5554a97f3 100644 --- a/ceph/ceph/debian/deb_folder/ceph-mgr.postinst +++ b/ceph/ceph/debian/deb_folder/ceph-mgr.postinst @@ -19,8 +19,8 @@ set -e # the debian-policy package [ -f "/etc/default/ceph" ] && . /etc/default/ceph -[ -z "$SERVER_USER" ] && SERVER_USER=ceph -[ -z "$SERVER_GROUP" ] && SERVER_GROUP=ceph +[ -z "$SERVER_USER" ] && SERVER_USER=root +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=root case "$1" in configure) diff --git a/ceph/ceph/debian/deb_folder/radosgw.postinst b/ceph/ceph/debian/deb_folder/radosgw.postinst index 3f1551269..0ab46868f 100644 --- a/ceph/ceph/debian/deb_folder/radosgw.postinst +++ b/ceph/ceph/debian/deb_folder/radosgw.postinst @@ -4,8 +4,8 @@ set -e if [ "${1}" = "configure" ] ; then [ -f "/etc/default/ceph" ] && . /etc/default/ceph - [ -z "$SERVER_USER" ] && SERVER_USER=ceph - [ -z "$SERVER_GROUP" ] && SERVER_GROUP=ceph + [ -z "$SERVER_USER" ] && SERVER_USER=root + [ -z "$SERVER_GROUP" ] && SERVER_GROUP=root if ! dpkg-statoverride --list /var/lib/ceph/radosgw >/dev/null; then chown $SERVER_USER:$SERVER_GROUP /var/lib/ceph/radosgw fi diff --git a/ceph/ceph/files/ceph-init-wrapper.sh b/ceph/ceph/files/ceph-init-wrapper.sh index 65bdab636..33f56c441 100755 --- a/ceph/ceph/files/ceph-init-wrapper.sh +++ b/ceph/ceph/files/ceph-init-wrapper.sh @@ -45,7 +45,11 @@ CEPH_STATUS_FAILURE_TEXT_FILE="/tmp/ceph_status_failure.txt" BINDIR=/usr/bin SBINDIR=/usr/sbin -LIBDIR=/usr/lib64/ceph +if grep -q "Debian" /etc/os-release; then + LIBDIR=/usr/lib/ceph +elif grep -q "CentOS" /etc/os-release; then + LIBDIR=/usr/lib64/ceph +fi ETCDIR=/etc/ceph source $LIBDIR/ceph_common.sh @@ -185,7 +189,11 @@ log_and_kill_hung_procs () date=$(date "+%Y-%m-%d_%H-%M-%S") log_file="$LOG_PATH/hang_trace_${name}_${pid}_${date}.log" wlog $name "INFO" "Dumping stack trace to: $log_file" - $(pstack $pid >$log_file) & + if grep -q "Debian" /etc/os-release; then + $(eu-stack -p $pid >$log_file) & + elif grep -q "CentOS" /etc/os-release; then + $(pstack $pid >$log_file) & + fi fi let monitoring-=1 sleep 1