Skip to content

Commit

Permalink
Merge "[ceph-client] update checkdns script logic to handle mon_host …
Browse files Browse the repository at this point in the history
…config"
  • Loading branch information
Zuul authored and openstack-gerrit committed Mar 4, 2020
2 parents c898325 + ffd0636 commit da0f5c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
11 changes: 4 additions & 7 deletions ceph-client/templates/bin/utils/_checkDNS.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions ceph-client/templates/bin/utils/_checkDNS_start.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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',')

if [[ ${PODS} == "" || ${ENDPOINT} == "" ]]; then
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
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
Expand Down
2 changes: 2 additions & 0 deletions ceph-client/templates/deployment-checkdns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions ceph-client/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ endpoints:
port:
mon:
default: 6789
mon_msgr2:
default: 3300
ceph_mgr:
namespace: null
hosts:
Expand Down

0 comments on commit da0f5c7

Please sign in to comment.