diff --git a/ceph-client/templates/bin/_helm-tests.sh.tpl b/ceph-client/templates/bin/_helm-tests.sh.tpl index 757c725cb..3c9609c19 100755 --- a/ceph-client/templates/bin/_helm-tests.sh.tpl +++ b/ceph-client/templates/bin/_helm-tests.sh.tpl @@ -43,7 +43,10 @@ function check_osd_count() { MIN_EXPECTED_OSDS=$(($EXPECTED_OSDS*$REQUIRED_PERCENT_OF_OSDS/100)) fi - if [ "${num_osd}" -ge "${MIN_EXPECTED_OSDS}" ] && [ "${num_in_osds}" -ge "${MIN_EXPECTED_OSDS}" ] && [ "${num_up_osds}" -ge "${MIN_EXPECTED_OSDS}" ]; then + if [ "${num_osd}" -eq 0 ]; then + echo "There are no osds in the cluster" + exit 1 + elif [ "${num_in_osds}" -ge "${MIN_EXPECTED_OSDS}" ] && [ "${num_up_osds}" -ge "${MIN_EXPECTED_OSDS}" ]; then echo "Required number of OSDs (${MIN_EXPECTED_OSDS}) are UP and IN status" else echo "Required number of OSDs (${MIN_EXPECTED_OSDS}) are NOT UP and IN status. Cluster shows OSD count=${num_osd}, UP=${num_up_osds}, IN=${num_in_osds}" diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml index 2ed98532c..eb26d10f9 100644 --- a/ceph-client/values.yaml +++ b/ceph-client/values.yaml @@ -232,7 +232,7 @@ conf: osd: 5 # This is just for helm tests to proceed the deployment if we have mentioned % of # osds are up and running. - required_percent_of_osds: 80 + required_percent_of_osds: 75 pg_per_osd: 100 protected: true #NOTE(st053q): target quota should be set to the overall cluster full percentage diff --git a/ceph-osd/templates/bin/_helm-tests.sh.tpl b/ceph-osd/templates/bin/_helm-tests.sh.tpl index 6c5176383..7e125ff38 100644 --- a/ceph-osd/templates/bin/_helm-tests.sh.tpl +++ b/ceph-osd/templates/bin/_helm-tests.sh.tpl @@ -18,30 +18,28 @@ limitations under the License. set -ex -# Check OSD status -function check_osd_status() { - echo "--Start: Checking OSD status--" - ceph_osd_stat_output=$(ceph osd stat -f json) - # - # Extract each value needed to check correct deployment of the OSDs - # - num_osds=$(echo $ceph_osd_stat_output | jq '.num_osds') - up_osds=$(echo $ceph_osd_stat_output | jq '.num_up_osds') - in_osds=$(echo $ceph_osd_stat_output | jq '.num_in_osds') - # - #NOTE: This check will fail if deployed OSDs are not running correctly - #In a correctly deployed cluster the number of UP and IN OSDs must be - #the same as the total number of OSDs +function check_osd_count() { + echo "#### Start: Checking OSD count ####" + osd_stat_output=$(ceph osd stat -f json-pretty) + num_osd=$(echo $osd_stat_output | jq .num_osds) + num_in_osds=$(echo $osd_stat_output | jq .num_in_osds) + num_up_osds=$(echo $osd_stat_output | jq .num_up_osds) - if [ "x${num_osds}" == "x0" ] ; then + if [ ${num_osd} -eq 1 ]; then + MIN_OSDS=${num_osd} + else + MIN_OSDS=$((${num_osd}*$REQUIRED_PERCENT_OF_OSDS/100)) + fi + + if [ "${num_osd}" -eq 0 ]; then echo "There are no osds in the cluster" exit 1 - elif [ "x${num_osds}" == "x${up_osds}" ] && [ "x${num_osds}" == "x${in_osds}" ] ; then - echo "Success: Total OSDs=${num_osds} Up=${up_osds} In=${in_osds}" + elif [ "${num_in_osds}" -ge "${MIN_OSDS}" ] && [ "${num_up_osds}" -ge "${MIN_OSDS}" ]; then + echo "Required number of OSDs (${MIN_OSDS}) are UP and IN status" else - echo "Failure: Total OSDs=${num_osds} Up=${up_osds} In=${in_osds}" + echo "Required number of OSDs (${MIN_OSDS}) are NOT UP and IN status. Cluster shows OSD count=${num_osd}, UP=${num_up_osds}, IN=${num_in_osds}" exit 1 fi } -check_osd_status +check_osd_count diff --git a/ceph-osd/templates/pod-helm-tests.yaml b/ceph-osd/templates/pod-helm-tests.yaml index 3d1740a84..fdb6fdc7d 100644 --- a/ceph-osd/templates/pod-helm-tests.yaml +++ b/ceph-osd/templates/pod-helm-tests.yaml @@ -44,6 +44,8 @@ spec: env: - name: CEPH_DEPLOYMENT_NAMESPACE value: {{ .Release.Namespace }} + - name: REQUIRED_PERCENT_OF_OSDS + value: {{ .Values.conf.ceph.target.required_percent_of_osds | ceil | quote }} command: - /tmp/helm-tests.sh volumeMounts: diff --git a/ceph-osd/values.yaml b/ceph-osd/values.yaml index e050dd272..4ae63d07c 100644 --- a/ceph-osd/values.yaml +++ b/ceph-osd/values.yaml @@ -186,6 +186,10 @@ conf: osd_mount_options_xfs: "rw,noatime,largeio,inode64,swalloc,logbufs=8,logbsize=256k,allocsize=4M" osd_journal_size: 10240 osd_crush_update_on_start: false + target: + # This is just for helm tests to proceed the deployment if we have mentioned % of + # osds are up and running. + required_percent_of_osds: 75 storage: # NOTE(supamatt): By default use host based buckets for failure domains. Any `failure_domain` defined must