From b9fcbf2c030eeb05421b5a9f0a67d3a2e745499f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 29 Oct 2021 09:53:43 -0500 Subject: [PATCH] Revert "Merge pull request #41325 from rhcs-dashboard/wip-cephadm_box-master" This reverts commit 78d6ac0d35e8db037bb0f42935528cc9fecf2d84, reversing changes made to 9a8de97f7af473a6a773323a463dc6603d7f4d39. This broke cephadm (infers config when it should not) Signed-off-by: Sage Weil --- ceph.spec.in | 2 - .../ceph_volume/devices/lvm/common.py | 6 - .../ceph_volume/devices/lvm/prepare.py | 7 +- src/ceph-volume/ceph_volume/process.py | 5 - src/cephadm/box/Dockerfile | 36 ---- src/cephadm/box/bootstrap.sh | 108 ----------- src/cephadm/box/docker-compose.yml | 44 ----- src/cephadm/box/docker/ceph/.bashrc | 0 src/cephadm/box/docker/ceph/Dockerfile | 9 - src/cephadm/box/docker/ceph/locale.conf | 2 - src/cephadm/box/get_ceph_image.sh | 12 -- src/cephadm/box/setup_loop.sh | 63 ------- src/cephadm/box/setup_ssh.sh | 50 ----- src/cephadm/box/start | 45 ----- src/cephadm/cephadm | 171 ++---------------- 15 files changed, 19 insertions(+), 541 deletions(-) delete mode 100644 src/cephadm/box/Dockerfile delete mode 100755 src/cephadm/box/bootstrap.sh delete mode 100644 src/cephadm/box/docker-compose.yml delete mode 100644 src/cephadm/box/docker/ceph/.bashrc delete mode 100644 src/cephadm/box/docker/ceph/Dockerfile delete mode 100644 src/cephadm/box/docker/ceph/locale.conf delete mode 100755 src/cephadm/box/get_ceph_image.sh delete mode 100755 src/cephadm/box/setup_loop.sh delete mode 100755 src/cephadm/box/setup_ssh.sh delete mode 100755 src/cephadm/box/start diff --git a/ceph.spec.in b/ceph.spec.in index 2c61b7e8bc4fd..3579d7e628eaf 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -465,8 +465,6 @@ Summary: Utility to bootstrap Ceph clusters BuildArch: noarch Requires: lvm2 Requires: python%{python3_pkgversion} -Requires: openssh-server -Requires: which %if 0%{?weak_deps} Recommends: podman >= 2.0.2 %endif diff --git a/src/ceph-volume/ceph_volume/devices/lvm/common.py b/src/ceph-volume/ceph_volume/devices/lvm/common.py index b7ce6473dd7a8..752f354f35aac 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/common.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/common.py @@ -123,12 +123,6 @@ bluestore_args = { 'type': int, 'default': 1, }, - '--no-tmpfs': { - 'action': 'store_true', - 'dest': 'no_tmpfs', - 'help': ('Disable tmpfs osd data directory with bluestore.' - 'Useful if you want to run lvm preprare from cephadm'), - }, } filestore_args = { diff --git a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py index 6567c78d9f5ec..2f715fdba122c 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py @@ -81,7 +81,7 @@ def prepare_filestore(device, journal, secrets, tags, osd_id, fsid): ) -def prepare_bluestore(block, wal, db, secrets, tags, osd_id, fsid, tmpfs=True): +def prepare_bluestore(block, wal, db, secrets, tags, osd_id, fsid): """ :param block: The name of the logical volume for the bluestore data :param wal: a regular/plain disk or logical volume, to be used for block.wal @@ -104,7 +104,7 @@ def prepare_bluestore(block, wal, db, secrets, tags, osd_id, fsid, tmpfs=True): db = prepare_dmcrypt(key, db, 'db', tags) # create the directory - prepare_utils.create_osd_path(osd_id, tmpfs=tmpfs) + prepare_utils.create_osd_path(osd_id, tmpfs=True) # symlink the block prepare_utils.link_block(block, osd_id) # get the latest monmap @@ -384,8 +384,6 @@ class Prepare(object): tags['ceph.type'] = 'block' block_lv.set_tags(tags) - tmpfs = not self.args.no_tmpfs - prepare_bluestore( block_lv.lv_path, wal_device, @@ -394,7 +392,6 @@ class Prepare(object): tags, self.osd_id, osd_fsid, - tmpfs=tmpfs ) def main(self): diff --git a/src/ceph-volume/ceph_volume/process.py b/src/ceph-volume/ceph_volume/process.py index 400063ae085a3..e70986892b7fd 100644 --- a/src/ceph-volume/ceph_volume/process.py +++ b/src/ceph-volume/ceph_volume/process.py @@ -5,11 +5,6 @@ from select import select from ceph_volume import terminal from ceph_volume.util import as_bytes -import locale - -if locale.getpreferredencoding().upper() != 'UTF-8': - locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') - import logging logger = logging.getLogger(__name__) diff --git a/src/cephadm/box/Dockerfile b/src/cephadm/box/Dockerfile deleted file mode 100644 index 3b685a22e9cae..0000000000000 --- a/src/cephadm/box/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# https://developers.redhat.com/blog/2014/05/05/running-systemd-within-docker-container/ -FROM centos:8 as centos-systemd -ENV container docker -ENV CEPHADM_PATH=/usr/local/sbin/cephadm -#RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ -#rm -f /lib/systemd/system/multi-user.target.wants/*;\ -#rm -f /etc/systemd/system/*.wants/*;\ -#rm -f /lib/systemd/system/local-fs.target.wants/*; \ -#rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ -#rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ -#rm -f /lib/systemd/system/basic.target.wants/*;\ -#rm -f /lib/systemd/system/anaconda.target.wants/*; -RUN dnf -y install chrony firewalld lvm2 \ - openssh-server openssh-clients python3 \ - yum-utils sudo which && dnf clean all - -RUN systemctl enable chronyd firewalld sshd - - -FROM centos-systemd as centos-systemd-docker -# To cache cephadm images -RUN yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo -RUN dnf -y install docker-ce && \ - dnf clean all && systemctl enable docker - -# ssh utilities -RUN dnf install epel-release -y && dnf makecache && dnf install sshpass -y - -EXPOSE 8443 -EXPOSE 22 - -FROM centos-systemd-docker -WORKDIR /root -COPY start /usr/local/bin - -CMD [ "/usr/sbin/init" ] diff --git a/src/cephadm/box/bootstrap.sh b/src/cephadm/box/bootstrap.sh deleted file mode 100755 index 41ad55429b45f..0000000000000 --- a/src/cephadm/box/bootstrap.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash - -OSDS=1 -HOSTS=0 -SKIP_LOOP=0 -SKIP_BOOTSTRAP=0 - -function print_usage() { - echo "./bootstrap.sh [OPTIONS]" - echo "options:" - echo " --hosts n: number of hosts to add" - echo " --osds n: number of osds to add" - echo " --update-ceph-image: create/update ceph image" - echo " --update-box-image: create/update cephadm box image" - echo " --skip-create-loop: skip creating loopback device" - echo " --skip-bootstrap: skip deploying the containers" - echo " -l | --list-hosts: list available cephad-box hosts/seed" - echo " -h | --help: this help :)" -} - -function docker-ips() { - docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}} %tab% {{.Name}} %tab% {{.Config.Hostname}}' $(docker ps -aq) | sed 's#%tab%#\t#g' | sed 's#/##g' | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n -} - -while [ $# -ge 1 ]; do -case $1 in - -h | --help) - print_usage - exit - ;; - -l | --list-hosts) # TODO remove when ceph-ci updated - echo -e "IP\t\tName\t\t Hostname" - docker-ips | grep box - exit - ;; - --update-box-image) - echo Updating box image - docker build -t cephadm-box -f Dockerfile . - ;; - --update-ceph-image) # TODO remove when ceph-ci updated - echo Updating ceph image - source ./get_ceph_image.sh - ;; - --hosts) - HOSTS="$2" - echo "number of hosts: $HOSTS" - shift - ;; - --osds) - OSDS="$2" - echo "number of osds: $OSDS" - shift - ;; - --skip-create-loop) - echo Skiping loop creation - SKIP_LOOP=1 - ;; - --skip-bootstrap) - echo Skiping bootstrap of containers - SKIP_BOOTSTRAP=1 - ;; -esac -shift -done - -# TODO: remove when ceph-ci image has required deps -if [[ ! -a docker/ceph/image/quay.ceph.image.tar ]] -then - echo -e "\033[33mWARNING:\033[0m run ./get_ceph_image.sh to get an updated ceph-ci/ceph image with correct deps." - exit -fi - -if [[ $OSDS -eq 0 ]] -then - SKIP_LOOP=1 -fi - -if [[ $SKIP_LOOP -eq 0 ]] -then - source setup_loop.sh - create_loops $OSDS -fi - - -if [[ $SKIP_BOOTSTRAP -eq 0 ]] -then - # loops should be created before starting docker-compose or else docker could - # not find lvs - docker-compose down - docker-compose up --scale hosts=$HOSTS -d - sleep 3 - - IPS=$(docker-ips | grep "box_hosts" | awk '{ print $1 }') - echo "IPS: " - echo $IPS - - sudo sysctl net.ipv4.conf.all.forwarding=1 - sudo iptables -P FORWARD ACCEPT - - for ((i=1;i<=$HOSTS;i++)) - do - docker-compose exec --index=$i hosts /cephadm/box/setup_ssh.sh run-sshd - done - - docker-compose exec -e NUM_OSDS=${OSDS} seed /cephadm/box/start - - docker-compose exec -e HOST_IPS="${IPS}" seed /cephadm/box/setup_ssh.sh copy-cluster-ssh-key -fi diff --git a/src/cephadm/box/docker-compose.yml b/src/cephadm/box/docker-compose.yml deleted file mode 100644 index 79271761f2d5f..0000000000000 --- a/src/cephadm/box/docker-compose.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: "2.4" -services: - cephadm-host-base: - build: - context: . - environment: - - CEPH_BRANCH=master - image: cephadm-box - # probably not needed with rootless Docker and cgroups v2 - privileged: true - cap_add: - - SYS_ADMIN - - NET_ADMIN - - SYS_TIME - - MKNOD - stop_signal: RTMIN+3 - volumes: - - "/sys/fs/cgroup:/sys/fs/cgroup:ro" - - ../../../:/ceph - - ..:/cephadm - networks: - - public - mem_limit: "20g" - devices: - - /dev/loop0:/dev/ttt:rwm - scale: -1 - seed: - extends: - service: cephadm-host-base - ports: - - "3000:3000" - - "8443:8443" - - "9095:9095" - scale: 1 - hosts: - extends: - service: cephadm-host-base - scale: 3 - - -volumes: - var-lib-docker: -networks: - public: diff --git a/src/cephadm/box/docker/ceph/.bashrc b/src/cephadm/box/docker/ceph/.bashrc deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/src/cephadm/box/docker/ceph/Dockerfile b/src/cephadm/box/docker/ceph/Dockerfile deleted file mode 100644 index 354728db2d181..0000000000000 --- a/src/cephadm/box/docker/ceph/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM quay.ceph.io/ceph-ci/ceph:master - -RUN dnf install which sudo glibc-all-langpacks langpacks-en -y -RUN yum -y install glibc-locale-source glibc-langpack-en - -RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8 -COPY locale.conf /etc/locale.conf - -EXPOSE 8443 diff --git a/src/cephadm/box/docker/ceph/locale.conf b/src/cephadm/box/docker/ceph/locale.conf deleted file mode 100644 index 00d76c8cdb651..0000000000000 --- a/src/cephadm/box/docker/ceph/locale.conf +++ /dev/null @@ -1,2 +0,0 @@ -LANG="en_US.UTF-8" -LC_ALL="en_US.UTF-8" diff --git a/src/cephadm/box/get_ceph_image.sh b/src/cephadm/box/get_ceph_image.sh deleted file mode 100755 index 3c431c86695a2..0000000000000 --- a/src/cephadm/box/get_ceph_image.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -ex - -IMAGE=quay.ceph.io/ceph-ci/ceph:master -docker pull $IMAGE -# update image with deps -docker build -t $IMAGE docker/ceph -# store to later load within docker -mkdir -p docker/ceph/image -rm -f docker/ceph/image/quay.ceph.image.tar -docker save quay.ceph.io/ceph-ci/ceph:master -o docker/ceph/image/quay.ceph.image.tar diff --git a/src/cephadm/box/setup_loop.sh b/src/cephadm/box/setup_loop.sh deleted file mode 100755 index 661715e803149..0000000000000 --- a/src/cephadm/box/setup_loop.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -set -e - -function create_loops() { - - NUM_OSDS=$1 - if [[ -z $NUM_OSDS ]]; then - echo "Call setup_loop to setup with more osds" - echo "Using default number of osds: 1." - NUM_OSDS=1 - fi - - # minimum 5 GB for each osd - SIZE=$(expr $NUM_OSDS \* 5) - # extra space just in case - SIZE=$(expr $SIZE + 2) - - echo "Using ${SIZE} GB of space" - - # look for an available loop device - avail_loop=$(sudo losetup -f) - loop_name=$(basename -- $avail_loop) - - if [[ ! -e $avail_loop ]] - then - # in case we have to create the loop, find the minor device number. - num_loops=$(lsmod | grep loop | awk '{print $3}') - num_loops=$((num_loops + 1)) - echo creating loop $avail_loop minor: $num_loops - mknod $avail_loop b 7 $num_loops - fi - - if mountpoint -q $avail_loop - then - sudo umount $avail_loop - fi - - if [[ ! -z $(losetup -l | grep $avail_loop) ]] - then - sudo losetup -d $avail_loop - fi - - if [[ ! -e loop-images ]] - then - mkdir -p loop-images - fi - sudo rm -f loop-images/* - sudo dd if=/dev/zero of="loop-images/disk${loop_name}.img" bs=1G count=$SIZE - sudo losetup $avail_loop "loop-images/disk${loop_name}.img" - - if [[ ! -z $(sudo vgs | grep vg1) ]] - then - sudo lvm vgremove -f -y vg1 - fi - sudo pvcreate $avail_loop - sudo vgcreate vg1 $avail_loop - - for ((i=0;i<$NUM_OSDS;i++)); do - sudo vgchange --refresh - sudo lvcreate --size 5G --name "lv${i}" "vg1" - done; -} diff --git a/src/cephadm/box/setup_ssh.sh b/src/cephadm/box/setup_ssh.sh deleted file mode 100755 index 5b81c2cbf6852..0000000000000 --- a/src/cephadm/box/setup_ssh.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -set -e - -function run-sshd() { - echo "Creating sshd server on $(hostname):$(hostname -i)" - # SSH - if [[ ! -f "/root/.ssh/id_rsa" ]]; then - mkdir -p ~/.ssh - chmod 700 ~/.ssh - ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N "" - fi - - cat ~/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys - if [[ ! -f "/root/.ssh/known_hosts" ]]; then - ssh-keygen -A - fi - - # change password - echo "root:root" | chpasswd - echo "PermitRootLogin yes" >> /etc/ssh/sshd_config - echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config - - /usr/sbin/sshd - echo "sshd finished" -} - -function copy-cluster-ssh-key() { - echo "Adding cluster ssh key to all hosts: ${HOST_IPS}" - HOST_IPS=$(echo $HOST_IPS) - for ip in $(echo $HOST_IPS) - do - if [[ ! $ip == $(hostname -i) ]] - then - echo $ip - # copy cluster key - sshpass -p "root" ssh-copy-id -f -o StrictHostKeyChecking=no -i /etc/ceph/ceph.pub "root@${ip}" - fi - done - echo "Finished adding keys, you can now add existing hosts containers to the cluster!" -} - -case $1 in - run-sshd) - run-sshd - ;; - copy-cluster-ssh-key) - copy-cluster-ssh-key - ;; -esac diff --git a/src/cephadm/box/start b/src/cephadm/box/start deleted file mode 100755 index b5883eeb932cc..0000000000000 --- a/src/cephadm/box/start +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -# link so we can debug cephadm -ln -s -f /cephadm/cephadm $CEPHADM_PATH -chmod +x $CEPHADM_PATH - -tail -f /var/log/ceph/cephadm.log 1>&2 & - -EXTRA_ARGS=() -if [[ -n "${SHARED_CEPH_FOLDER-}" ]]; then - EXTRA_ARGS+=(--shared_ceph_folder "$SHARED_CEPH_FOLDER") -fi - -docker load < /cephadm/box/docker/ceph/image/quay.ceph.image.tar - -# cephadm guid error because it sometimes tries to use quay.ceph.io/ceph-ci/ceph: -# instead of master's tag -export CEPHADM_IMAGE=quay.ceph.io/ceph-ci/ceph:master -echo "export CEPHADM_IMAGE=quay.ceph.io/ceph-ci/ceph:master" >> ~/.bashrc - -if [[ -n "$CEPHADM_IMAGE" ]]; then - EXTRA_ARGS+=--skip-pull -fi - -export CEPH_SOURCE_FOLDER=/ceph -$CEPHADM_PATH --verbose bootstrap \ - --mon-ip "$(hostname -i)" \ - --allow-fqdn-hostname \ - --initial-dashboard-password admin \ - --dashboard-password-noupdate \ - --shared_ceph_folder /ceph \ - "${EXTRA_ARGS[@]}" - -# make sure vg and lvs are visible -vgchange --refresh -for((i=0;i<$NUM_OSDS;i++)); do - echo "Creating osd.${i}" - # create osd folder - $CEPHADM_PATH ceph-volume --shared_ceph_folder /ceph lvm create --bluestore --no-tmpfs --data "/dev/vg1/lv${i}" --no-systemd - echo "Deploying osd.${i}..." - # deploy osd with osd data folder - $CEPHADM_PATH deploy --name "osd.${i}" - echo "osd.${i} deployed!" -done; diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index ef41c1aea7a20..35ef6e279e6f9 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1783,6 +1783,7 @@ def default_image(func: FuncT) -> FuncT: ctx.image = _get_default_image(ctx) return func(ctx) + return cast(FuncT, _default_image) @@ -2214,6 +2215,7 @@ def create_daemon_dirs(ctx, fsid, daemon_type, daemon_id, uid, gid, # type: (CephadmContext, str, str, Union[int, str], int, int, Optional[str], Optional[str]) -> None data_dir = make_data_dir(ctx, fsid, daemon_type, daemon_id, uid=uid, gid=gid) make_log_dir(ctx, fsid, uid=uid, gid=gid) + if config: config_path = os.path.join(data_dir, 'config') with open(config_path, 'w') as f: @@ -2612,79 +2614,6 @@ def extract_uid_gid(ctx, img='', file_path='/var/lib/ceph'): raise RuntimeError('uid/gid not found') -def validate_osd_data_dir(data_dir): - # type: (str) -> None - required_files = ['keyring', 'block', 'type', 'config'] - current_files = os.listdir(data_dir) - error_msg = '' - for file in required_files: - if file not in current_files: - error_msg += f'File {file} not found in {data_dir}\n' - if error_msg: - raise RuntimeError(error_msg) - - -def configure_osd_data_dir(ctx, fsid, daemon_id, uid, gid): - # type: (CephadmContext, str, Union[int, str], int, int) -> None - daemon_type = 'osd' - data_dir = get_data_dir(fsid, ctx.data_dir, daemon_type, daemon_id) - - # Ensure user:group is the expected - for f in os.listdir(data_dir): - os.chown(os.path.join(data_dir, f), uid, gid) - - # Create minimal config - touch(os.path.join(data_dir, 'config'), uid, gid) - mounts = get_container_mounts(ctx, fsid, daemon_type, daemon_id, no_config=True) - mounts[data_dir] = '/var/lib/ceph/osd/ceph-%s' % daemon_id - mounts['/etc/ceph/ceph.conf'] = '/etc/ceph/ceph.conf:z' - mounts['/etc/ceph/ceph.client.admin.keyring'] = '/etc/ceph/ceph.keyring:z' - - CephContainer( - ctx, - image=ctx.image, - entrypoint='/usr/bin/ceph', - args=[ - 'config', 'generate-minimal-conf', - '-o', '/var/lib/ceph/osd/ceph-%s/config' % daemon_id - ], - privileged=True, - volume_mounts=mounts - ).run() - - # Create keyring and then import - key = CephContainer( - ctx, - image=ctx.image, - entrypoint='/usr/bin/ceph-authtool', - args=['--gen-print-key'], - ).run().strip() - - keyring = ('[%s.%s]\n' - '\tkey = %s\n' - '\tcaps osd = allow *\n' - '\tcaps mon = allow *\n' - % (daemon_type, daemon_id, key)) - with open(os.path.join(data_dir, 'keyring'), 'w+') as f: - os.fchmod(f.fileno(), 0o600) - os.fchown(f.fileno(), uid, gid) - f.write(keyring) - CephContainer( - ctx, - image=ctx.image, - entrypoint='/usr/bin/ceph', - args=[ - 'auth', 'import', - '-i', '/var/lib/ceph/osd/ceph-%s/keyring' % daemon_id - ], - privileged=True, - volume_mounts=mounts - ).run() - - # Validate we have needed files - validate_osd_data_dir(data_dir) - - def deploy_daemon(ctx, fsid, daemon_type, daemon_id, c, uid, gid, config=None, keyring=None, osd_fsid=None, @@ -2751,9 +2680,6 @@ def deploy_daemon(ctx, fsid, daemon_type, daemon_id, c, uid, gid, uid, gid, config, keyring) - if daemon_type == 'osd': - configure_osd_data_dir(ctx, fsid, daemon_id, uid, gid) - if not reconfig: if daemon_type == CephadmAgent.daemon_type: if ctx.config_json == '-': @@ -2865,14 +2791,6 @@ def deploy_daemon_units( ) -> None: # cmd data_dir = get_data_dir(fsid, ctx.data_dir, daemon_type, daemon_id) - - # if osd then try to read parameters if not provided - if daemon_type == 'osd': - osd_fsid_path = os.path.join(data_dir, 'fsid') - if 'fsid' in os.listdir(data_dir) and not osd_fsid: - with open(osd_fsid_path, 'r') as f: - osd_fsid = f.read() - with open(data_dir + '/unit.run.new', 'w') as f, \ open(data_dir + '/unit.meta.new', 'w') as metaf: f.write('set -e\n') @@ -3002,9 +2920,7 @@ def deploy_daemon_units( verbosity=CallVerbosity.DEBUG) if enable: call_throws(ctx, ['systemctl', 'enable', unit_name]) - if start: - clean_cgroup(ctx, fsid, unit_name) call_throws(ctx, ['systemctl', 'start', unit_name]) @@ -4791,10 +4707,8 @@ def extract_uid_gid_monitoring(ctx, daemon_type): @default_image -@infer_fsid def command_deploy(ctx): # type: (CephadmContext) -> None - assert ctx.fsid daemon_type, daemon_id = ctx.name.split('.', 1) lock = FileLock(ctx, ctx.fsid) @@ -4975,7 +4889,6 @@ def command_shell(ctx): mounts[pathify(ctx.config)] = '/etc/ceph/ceph.conf:z' if ctx.keyring: mounts[pathify(ctx.keyring)] = '/etc/ceph/ceph.keyring:z' - if ctx.mount: for _mount in ctx.mount: split_src_dst = _mount.split(':') @@ -5077,6 +4990,7 @@ def command_ceph_volume(ctx): (uid, gid) = (0, 0) # ceph-volume runs as root mounts = get_container_mounts(ctx, ctx.fsid, 'osd', None) + tmp_config = None tmp_keyring = None @@ -5087,72 +5001,24 @@ def command_ceph_volume(ctx): tmp_config = write_tmp(config, uid, gid) mounts[tmp_config.name] = '/etc/ceph/ceph.conf:z' - # Ceph-volume uses the bootstrap-osd key in order to do its operations. - # This function retrieves the keyring so it can be provided. - - def get_bootstrap_osd_keyring() -> Optional[str]: - if not ctx.keyring and os.path.exists(SHELL_DEFAULT_KEYRING): - ctx.keyring = SHELL_DEFAULT_KEYRING - (config, keyring) = get_config_and_keyring(ctx) - - mounts = get_container_mounts(ctx, ctx.fsid, 'osd', None, - no_config=True if ctx.config else False) - if ctx.config: - mounts[pathify(ctx.config)] = '/etc/ceph/ceph.conf:z' - if ctx.keyring: - mounts[pathify(ctx.keyring)] = '/etc/ceph/ceph.keyring:z' - c = CephContainer( - ctx, - image=ctx.image, - entrypoint='/usr/bin/ceph', - args='auth get client.bootstrap-osd'.split(), - volume_mounts=mounts, - ) - out, err, code = call_throws(ctx, c.run_cmd()) - if not code: - return out - else: - return None - - if not keyring: - keyring = get_bootstrap_osd_keyring() - if keyring: # tmp keyring file tmp_keyring = write_tmp(keyring, uid, gid) mounts[tmp_keyring.name] = '/var/lib/ceph/bootstrap-osd/ceph.keyring:z' - # If ceph-volume creates osd data directories which won't be persisted - # so we use a tmp dir for that. - # FIXME: probably we can use /var/lib/ceph/{fsid}? - with tempfile.TemporaryDirectory() as tmp_osd_dir: - # match /var/lib/ceph/osd/ dir permissions - os.chown(tmp_osd_dir, uid, gid) - os.chmod(tmp_osd_dir, 0o755) - # store newly created osds here - mounts[tmp_osd_dir] = '/var/lib/ceph/osd/:z' - - c = CephContainer( - ctx, - image=ctx.image, - entrypoint='/usr/sbin/ceph-volume', - envs=ctx.env, - args=ctx.command, - privileged=True, - volume_mounts=mounts, - ) + c = CephContainer( + ctx, + image=ctx.image, + entrypoint='/usr/sbin/ceph-volume', + envs=ctx.env, + args=ctx.command, + privileged=True, + volume_mounts=mounts, + ) - out, err, code = call_throws(ctx, c.run_cmd()) - if not code: - print(out) - else: - print(err) - # If osds were created move osd's data directories - for osd_folder_name in os.listdir(tmp_osd_dir): - if 'ceph-' in osd_folder_name[:5]: - osd_id = osd_folder_name[5:] - osd_data_dir = os.path.join(tmp_osd_dir, osd_folder_name) - copy_tree(ctx, [osd_data_dir], f'/var/lib/ceph/{ctx.fsid}/osd.{osd_id}', uid=uid, gid=gid) + out, err, code = call_throws(ctx, c.run_cmd()) + if not code: + print(out) ################################## @@ -7718,7 +7584,7 @@ def _get_parser(): help='cluster FSID') parser_ceph_volume.add_argument( '--config-json', - help='JSON file with config and (client.bootstrap-osd) key') + help='JSON file with config and (client.bootrap-osd) key') parser_ceph_volume.add_argument( '--config', '-c', help='ceph conf file') @@ -7728,10 +7594,6 @@ def _get_parser(): parser_ceph_volume.add_argument( 'command', nargs=argparse.REMAINDER, help='command') - parser_ceph_volume.add_argument( - '--shared_ceph_folder', - metavar='CEPH_SOURCE_FOLDER', - help='Development mode. Several folders in containers are volumes mapped to different sub-folders in the ceph source folder') parser_zap_osds = subparsers.add_parser( 'zap-osds', help='zap all OSDs associated with a particular fsid') @@ -7953,6 +7815,7 @@ def _get_parser(): help='daemon name (type.id)') parser_deploy.add_argument( '--fsid', + required=True, help='cluster FSID') parser_deploy.add_argument( '--config', '-c', -- 2.39.5