From ffd06369adc6ef6cf54977ecb2b0a379cec2f610 Mon Sep 17 00:00:00 2001 From: Chinasubbareddy Mallavarapu Date: Mon, 2 Mar 2020 08:46:20 -0600 Subject: [PATCH] [ceph-client] update checkdns script logic to handle mon_host config This is to update checkdns script loigc not to update ceph.conf when dns is up as current logic is repalcing ceph.conf file with configmap where we have fqdn for ceph-mon endpoint which is causing parsing issues in Nautilus. Change-Id: Iae2a38fdc99654430812451c57ac2655887f942a --- ceph-client/templates/bin/utils/_checkDNS.sh.tpl | 11 ++++------- .../templates/bin/utils/_checkDNS_start.sh.tpl | 12 ++++++++---- ceph-client/templates/deployment-checkdns.yaml | 2 ++ ceph-client/values.yaml | 2 ++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ceph-client/templates/bin/utils/_checkDNS.sh.tpl b/ceph-client/templates/bin/utils/_checkDNS.sh.tpl index 482dcaf67..2cd7d8991 100644 --- a/ceph-client/templates/bin/utils/_checkDNS.sh.tpl +++ b/ceph-client/templates/bin/utils/_checkDNS.sh.tpl @@ -17,17 +17,14 @@ limitations under the License. */}} : "${CEPH_CONF:="/etc/ceph/${CLUSTER}.conf"}" -ENDPOINT=$1 +ENDPOINT="{$1}" function check_mon_dns () { GREP_CMD=$(grep -rl 'ceph-mon' ${CEPH_CONF}) - if [[ ${ENDPOINT} == "up" ]]; then - # If DNS is working, we simply restore the ${CEPH_CONF} file - if [[ ${GREP_CMD} == "" ]]; then - sh -c -e "cat ${CEPH_CONF}.template | tee ${CEPH_CONF}" > /dev/null 2>&1 - fi - elif [[ ${ENDPOINT} != "" ]]; then + if [[ "${ENDPOINT}" == "up" ]]; then + echo "If DNS is working, we are good here" + elif [[ "${ENDPOINT}" != "" ]]; then if [[ ${GREP_CMD} != "" ]]; then # No DNS, write CEPH MONs IPs into ${CEPH_CONF} sh -c -e "cat ${CEPH_CONF}.template | sed 's/mon_host.*/mon_host = ${ENDPOINT}/g' | tee ${CEPH_CONF}" > /dev/null 2>&1 diff --git a/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl b/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl index c91a2b9ff..e9c303d8a 100644 --- a/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl +++ b/ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl @@ -20,15 +20,19 @@ set -xe function check_mon_dns { DNS_CHECK=$(getent hosts ceph-mon | head -n1) - PODS=$(kubectl get pods --namespace=${NAMESPACE} --selector=application=ceph --field-selector=status.phase=Running --output=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E 'ceph-mon|ceph-osd|ceph-mgr|ceph-mds') - ENDPOINT=$(kubectl get endpoints ceph-mon -n ${NAMESPACE} -o json | awk -F'"' -v port=${MON_PORT} '/ip/{print $4":"port}' | paste -sd',') + PODS=$(kubectl get pods --namespace=${NAMESPACE} --selector=application=ceph --field-selector=status.phase=Running \ + --output=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E 'ceph-mon|ceph-osd|ceph-mgr|ceph-mds') + ENDPOINT=$(kubectl get endpoints ceph-mon-discovery -n ${NAMESPACE} -o json | awk -F'"' -v port=${MON_PORT} \ + -v version=v1 -v msgr_version=v2 \ + -v msgr2_port=${MON_PORT_V2} \ + '/"ip"/{print "["version":"$4":"port"/"0","msgr_version":"$4":"msgr2_port"/"0"]"}' | paste -sd',') - if [[ ${PODS} == "" || ${ENDPOINT} == "" ]]; then + if [[ ${PODS} == "" || "${ENDPOINT}" == "" ]]; then echo "Something went wrong, no PODS or ENDPOINTS are available!" elif [[ ${DNS_CHECK} == "" ]]; then for POD in ${PODS}; do kubectl exec -t ${POD} --namespace=${NAMESPACE} -- \ - sh -c -e "/tmp/utils-checkDNS.sh ${ENDPOINT}" + sh -c -e "/tmp/utils-checkDNS.sh "${ENDPOINT}"" done else for POD in ${PODS}; do diff --git a/ceph-client/templates/deployment-checkdns.yaml b/ceph-client/templates/deployment-checkdns.yaml index 14bc97033..97559171d 100644 --- a/ceph-client/templates/deployment-checkdns.yaml +++ b/ceph-client/templates/deployment-checkdns.yaml @@ -97,6 +97,8 @@ spec: fieldPath: metadata.namespace - name: MON_PORT value: {{ tuple "ceph_mon" "internal" "mon" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} + - name: MON_PORT_V2 + value: {{ tuple "ceph_mon" "internal" "mon_msgr2" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} - name: KUBECTL_PARAM value: {{ tuple $envAll "ceph" "checkdns" | include "helm-toolkit.snippets.kubernetes_kubectl_params" | indent 10 }} command: diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml index 0ba52e84c..e5f788890 100644 --- a/ceph-client/values.yaml +++ b/ceph-client/values.yaml @@ -527,6 +527,8 @@ endpoints: port: mon: default: 6789 + mon_msgr2: + default: 3300 ceph_mgr: namespace: null hosts: