Add pre-check of storage locations
Since we are about to use wildcards in storage locations, it is possible to have multiple matches, so we need to add precheck before using $STORAGE_LOCATION, $BLOCK_DB and $BLOCK_WAL variables to ensure that stored strings resolve to just one and only block location. Signed-off-by: Ruslan Aliev <raliev@mirantis.com> Change-Id: I60180f988e90473e200e886b69788cc263359ad2
This commit is contained in:
parent
b5c285ae98
commit
109c629838
@ -15,6 +15,6 @@ apiVersion: v1
|
|||||||
appVersion: v1.0.0
|
appVersion: v1.0.0
|
||||||
description: OpenStack-Helm Ceph OSD
|
description: OpenStack-Helm Ceph OSD
|
||||||
name: ceph-osd
|
name: ceph-osd
|
||||||
version: 0.1.35
|
version: 0.1.36
|
||||||
home: https://github.com/ceph/ceph
|
home: https://github.com/ceph/ceph
|
||||||
...
|
...
|
||||||
|
@ -16,6 +16,8 @@ limitations under the License.
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
source /tmp/utils-resolveLocations.sh
|
||||||
|
|
||||||
if [ "x${STORAGE_TYPE%-*}" == "xblock" ]; then
|
if [ "x${STORAGE_TYPE%-*}" == "xblock" ]; then
|
||||||
OSD_DEVICE=$(readlink -f ${STORAGE_LOCATION})
|
OSD_DEVICE=$(readlink -f ${STORAGE_LOCATION})
|
||||||
OSD_JOURNAL=$(readlink -f ${JOURNAL_LOCATION})
|
OSD_JOURNAL=$(readlink -f ${JOURNAL_LOCATION})
|
||||||
|
@ -20,6 +20,8 @@ export lock_fd=''
|
|||||||
export ALREADY_LOCKED=0
|
export ALREADY_LOCKED=0
|
||||||
export PS4='+${BASH_SOURCE:+$(basename ${BASH_SOURCE}):${LINENO}:}${FUNCNAME:+${FUNCNAME}():} '
|
export PS4='+${BASH_SOURCE:+$(basename ${BASH_SOURCE}):${LINENO}:}${FUNCNAME:+${FUNCNAME}():} '
|
||||||
|
|
||||||
|
source /tmp/utils-resolveLocations.sh
|
||||||
|
|
||||||
: "${CRUSH_LOCATION:=root=default host=${HOSTNAME}}"
|
: "${CRUSH_LOCATION:=root=default host=${HOSTNAME}}"
|
||||||
: "${OSD_PATH_BASE:=/var/lib/ceph/osd/${CLUSTER}}"
|
: "${OSD_PATH_BASE:=/var/lib/ceph/osd/${CLUSTER}}"
|
||||||
: "${CEPH_CONF:="/etc/ceph/${CLUSTER}.conf"}"
|
: "${CEPH_CONF:="/etc/ceph/${CLUSTER}.conf"}"
|
||||||
|
@ -16,6 +16,8 @@ limitations under the License.
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
source /tmp/utils-resolveLocations.sh
|
||||||
|
|
||||||
if [ "x${STORAGE_TYPE%-*}" == "xblock" ]; then
|
if [ "x${STORAGE_TYPE%-*}" == "xblock" ]; then
|
||||||
OSD_DEVICE=$(readlink -f ${STORAGE_LOCATION})
|
OSD_DEVICE=$(readlink -f ${STORAGE_LOCATION})
|
||||||
ODEV=$(echo ${OSD_DEVICE} | sed 's/[0-9]//g' | cut -f 3 -d '/')
|
ODEV=$(echo ${OSD_DEVICE} | sed 's/[0-9]//g' | cut -f 3 -d '/')
|
||||||
|
41
ceph-osd/templates/bin/utils/_resolveLocations.sh.tpl
Normal file
41
ceph-osd/templates/bin/utils/_resolveLocations.sh.tpl
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
if [[ "${STORAGE_LOCATION}" ]]; then
|
||||||
|
STORAGE_LOCATION=$(ls ${STORAGE_LOCATION})
|
||||||
|
if [[ `echo "${STORAGE_LOCATION}" | wc -w` -ge 2 ]]; then
|
||||||
|
echo "ERROR- Multiple locations found: ${STORAGE_LOCATION}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${BLOCK_DB}" ]]; then
|
||||||
|
BLOCK_DB=$(ls ${BLOCK_DB})
|
||||||
|
if [[ `echo "${BLOCK_DB}" | wc -w` -ge 2 ]]; then
|
||||||
|
echo "ERROR- Multiple locations found: ${BLOCK_DB}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${BLOCK_WAL}" ]]; then
|
||||||
|
BLOCK_WAL=$(ls ${BLOCK_WAL})
|
||||||
|
if [[ `echo "${BLOCK_WAL}" | wc -w` -ge 2 ]]; then
|
||||||
|
echo "ERROR- Multiple locations found: ${BLOCK_WAL}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
@ -64,4 +64,6 @@ data:
|
|||||||
{{ tuple "bin/utils/_checkDNS.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
{{ tuple "bin/utils/_checkDNS.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
||||||
utils-defragOSDs.sh: |
|
utils-defragOSDs.sh: |
|
||||||
{{ tuple "bin/utils/_defragOSDs.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
{{ tuple "bin/utils/_defragOSDs.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
||||||
|
utils-resolveLocations.sh: |
|
||||||
|
{{ tuple "bin/utils/_resolveLocations.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -240,6 +240,10 @@ spec:
|
|||||||
mountPath: /tmp/osd-common-ceph-volume.sh
|
mountPath: /tmp/osd-common-ceph-volume.sh
|
||||||
subPath: osd-common-ceph-volume.sh
|
subPath: osd-common-ceph-volume.sh
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
- name: ceph-osd-bin
|
||||||
|
mountPath: /tmp/utils-resolveLocations.sh
|
||||||
|
subPath: utils-resolveLocations.sh
|
||||||
|
readOnly: true
|
||||||
- name: ceph-osd-etc
|
- name: ceph-osd-etc
|
||||||
mountPath: /etc/ceph/ceph.conf.template
|
mountPath: /etc/ceph/ceph.conf.template
|
||||||
subPath: ceph.conf
|
subPath: ceph.conf
|
||||||
@ -403,6 +407,10 @@ spec:
|
|||||||
mountPath: /tmp/osd-common-ceph-volume.sh
|
mountPath: /tmp/osd-common-ceph-volume.sh
|
||||||
subPath: osd-common-ceph-volume.sh
|
subPath: osd-common-ceph-volume.sh
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
- name: ceph-osd-bin
|
||||||
|
mountPath: /tmp/utils-resolveLocations.sh
|
||||||
|
subPath: utils-resolveLocations.sh
|
||||||
|
readOnly: true
|
||||||
- name: ceph-osd-bin
|
- name: ceph-osd-bin
|
||||||
mountPath: /tmp/utils-defragOSDs.sh
|
mountPath: /tmp/utils-defragOSDs.sh
|
||||||
subPath: utils-defragOSDs.sh
|
subPath: utils-defragOSDs.sh
|
||||||
|
@ -36,4 +36,5 @@ ceph-osd:
|
|||||||
- 0.1.33 Update log-runner container for MAC
|
- 0.1.33 Update log-runner container for MAC
|
||||||
- 0.1.34 Remove wait for misplaced objects during OSD restarts
|
- 0.1.34 Remove wait for misplaced objects during OSD restarts
|
||||||
- 0.1.35 Consolidate mon_endpoints discovery
|
- 0.1.35 Consolidate mon_endpoints discovery
|
||||||
|
- 0.1.36 Add OSD device location pre-check
|
||||||
...
|
...
|
||||||
|
Loading…
Reference in New Issue
Block a user