From 621d3938db888a5a5a52759ad68b61f4c3522845 Mon Sep 17 00:00:00 2001 From: Matthew Heler Date: Mon, 3 Dec 2018 20:36:52 -0600 Subject: [PATCH] Fix racy conditions with Ceph caps updating The sed commands are replaced with simpler methods of extracting the cephx cap keys. Change-Id: I783c360569bf17b16d128544b5ab11cb1ce9a7ed --- gnocchi/templates/bin/_storage-init.sh.tpl | 3 +-- libvirt/templates/bin/_ceph-keyring.sh.tpl | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gnocchi/templates/bin/_storage-init.sh.tpl b/gnocchi/templates/bin/_storage-init.sh.tpl index 2d6d8a057..f73cc1392 100644 --- a/gnocchi/templates/bin/_storage-init.sh.tpl +++ b/gnocchi/templates/bin/_storage-init.sh.tpl @@ -42,8 +42,7 @@ if USERINFO=$(ceph auth get client.${RBD_POOL_USER}); then mon "profile r" \ osd "profile rwx pool=${RBD_POOL_NAME}" \ mgr "allow r" - KEYSTR=$(echo $USERINFO | sed 's/.*\( key = .*\) caps mon.*/\1/') - echo $KEYSTR > ${KEYRING} + ceph auth get client.${RBD_POOL_USER} -o ${KEYRING} else ceph auth get-or-create client.${RBD_POOL_USER} \ mon "profile r" \ diff --git a/libvirt/templates/bin/_ceph-keyring.sh.tpl b/libvirt/templates/bin/_ceph-keyring.sh.tpl index 0cd536291..d7007d566 100644 --- a/libvirt/templates/bin/_ceph-keyring.sh.tpl +++ b/libvirt/templates/bin/_ceph-keyring.sh.tpl @@ -20,6 +20,12 @@ set -ex export HOME=/tmp KEYRING=/etc/ceph/ceph.client.${CEPH_CINDER_USER}.keyring +{{- if .Values.conf.ceph.cinder.keyring }} +cat > ${KEYRING} < ${KEYRING} + ceph auth get client.${CEPH_CINDER_USER} -o ${KEYRING} else echo "Creating Cephx user client.${CEPH_CINDER_USER}" ceph auth get-or-create client.${CEPH_CINDER_USER} \ @@ -43,3 +48,4 @@ if ! [ "x${CEPH_CINDER_USER}" == "xadmin" ]; then fi rm -f /etc/ceph/ceph.client.admin.keyring fi +{{- end }}