From 17df1c5df5700546f8e510037a7fa06587e2c9fb Mon Sep 17 00:00:00 2001
From: Renis Makadia <renis.makadia@att.com>
Date: Tue, 30 Oct 2018 11:52:31 -0700
Subject: [PATCH] Ceph: Journal partition automation

- Use whole disk /dev/sdc format.
- Don't specify partition and let ceph-osd util create
and manage partition.
- On an OSD disk failure, during manintanance window,
Journal partition for failed OSD should be deleted.
This will allow ceph-osd util to reuse space for new partition.
- Disk partition count num will continue to
increase as more OSD fails.

Change-Id: I87522db8cabebe8cb103481cdb65fc52f2ce2b07
---
 ceph-osd/templates/bin/osd/_block.sh.tpl | 1 -
 ceph-osd/templates/bin/osd/_init.sh.tpl  | 4 +++-
 ceph-osd/values.yaml                     | 3 +++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ceph-osd/templates/bin/osd/_block.sh.tpl b/ceph-osd/templates/bin/osd/_block.sh.tpl
index bcccb5fbc..eb3e4b40b 100644
--- a/ceph-osd/templates/bin/osd/_block.sh.tpl
+++ b/ceph-osd/templates/bin/osd/_block.sh.tpl
@@ -200,7 +200,6 @@ if [ "${OSD_BLUESTORE:-0}" -ne 1 ]; then
     chown ceph. "${JOURNAL_PART}" "${DATA_PART}"
     OSD_JOURNAL="${JOURNAL_PART}"
   fi
-  CEPH_OSD_OPTIONS="${CEPH_OSD_OPTIONS} --osd-journal ${OSD_JOURNAL}"
 fi
 
 if [ "x${JOURNAL_TYPE}" == "xdirectory" ]; then
diff --git a/ceph-osd/templates/bin/osd/_init.sh.tpl b/ceph-osd/templates/bin/osd/_init.sh.tpl
index a5cabfa49..354905ea9 100644
--- a/ceph-osd/templates/bin/osd/_init.sh.tpl
+++ b/ceph-osd/templates/bin/osd/_init.sh.tpl
@@ -22,6 +22,8 @@ set -ex
 : "${OSD_JOURNAL_UUID:=$(uuidgen)}"
 : "${OSD_FORCE_ZAP:=1}"
 : "${CEPH_CONF:="/etc/ceph/${CLUSTER}.conf"}"
+# We do not want to zap journal disk. Tracking this option seperatly.
+: "${JOURNAL_FORCE_ZAP:=0}"
 
 if [[ ! -e ${CEPH_CONF}.template ]]; then
   echo "ERROR- ${CEPH_CONF}.template must exist; get it from your existing mon"
@@ -203,7 +205,7 @@ function osd_disk_prepare {
     CLI_OPTS="${CLI_OPTS} --bluestore"
   fi
 
-  if [ -b "${OSD_JOURNAL}" -a "${OSD_FORCE_ZAP:-0}" -eq 1 ]; then
+  if [ -b "${OSD_JOURNAL}" -a "${JOURNAL_FORCE_ZAP:-0}" -eq 1 ]; then
     # if we got here and zap is set, it's ok to wipe the journal.
     echo "OSD_FORCE_ZAP is set, so we will erase the journal device ${OSD_JOURNAL}"
     if [ -z "${OSD_JOURNAL_PARTITION}" ]; then
diff --git a/ceph-osd/values.yaml b/ceph-osd/values.yaml
index 0cd1440f2..3d9bb4e01 100644
--- a/ceph-osd/values.yaml
+++ b/ceph-osd/values.yaml
@@ -134,6 +134,8 @@ conf:
 
     # NOTE(portdirect): for homogeneous clusters the `osd` key can be used to
     # define OSD pods that will be deployed across the cluster.
+    # when specifing whole disk (/dev/sdf) for journals, ceph-osd chart will create
+    # needed partitions for each OSDs.
     osd:
       - data:
           type: directory
@@ -153,6 +155,7 @@ conf:
       #   journal:
       #     type: directory
       #     location: /var/lib/openstack-helm/ceph/osd/journal-sdg
+
 # NOTE(portdirect): for heterogeneous clusters the overrides section can be used to define
 # OSD pods that will be deployed upon specifc nodes.
 # overrides: