Update mon-check with latest monmap outputs

This PS updates the mon-check reap-zombies python script to consider
the more recent Ceph changes, including the fact that there is now
a v1 and v2 backend. In addition, it executes the reap-zombies script
with the python3 binary, as the basic 'python' binary does not exist
in the container.

Change-Id: Id079671f03cc5ddbe694f2aa8c9d2480dc573983
This commit is contained in:
DeJaeger, Darren (dd118r) 2021-07-30 10:35:59 -04:00 committed by chinasubbareddy mallavarapu
parent 9797d1b034
commit f26d4db145
4 changed files with 7 additions and 6 deletions

View File

@ -15,6 +15,6 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Ceph Mon
name: ceph-mon
version: 0.1.10
version: 0.1.11
home: https://github.com/ceph/ceph
...

View File

@ -4,7 +4,7 @@ import os
import subprocess # nosec
import json
MON_REGEX = r"^\d: ([0-9\.]*):\d+/\d* mon.([^ ]*)$"
MON_REGEX = r"^\d: \[((v\d+:([0-9\.]*):\d+\/\d+,*)+)] mon.([^ ]*)$"
# kubctl_command = 'kubectl get pods --namespace=${NAMESPACE} -l component=mon,application=ceph -o template --template="{ {{"}}"}}range .items{{"}}"}} \\"{{"}}"}}.metadata.name{{"}}"}}\\": \\"{{"}}"}}.status.podIP{{"}}"}}\\" , {{"}}"}}end{{"}}"}} }"'
if int(os.getenv('K8S_HOST_NETWORK', 0)) > 0:
kubectl_command = 'kubectl get pods --namespace=${NAMESPACE} -l component=mon,application=ceph -o template --template="{ {{"{{"}}range \$i, \$v := .items{{"}}"}} {{"{{"}} if \$i{{"}}"}} , {{"{{"}} end {{"}}"}} \\"{{"{{"}}\$v.spec.nodeName{{"}}"}}\\": \\"{{"{{"}}\$v.status.podIP{{"}}"}}\\" {{"{{"}}end{{"}}"}} }"'
@ -15,16 +15,16 @@ monmap_command = "ceph --cluster=${CLUSTER} mon getmap > /tmp/monmap && monmapto
def extract_mons_from_monmap():
monmap = subprocess.check_output(monmap_command, shell=True) # nosec
monmap = subprocess.check_output(monmap_command, shell=True).decode('utf-8') # nosec
mons = {}
for line in monmap.split("\n"):
m = re.match(MON_REGEX, line)
if m is not None:
mons[m.group(2)] = m.group(1)
mons[m.group(4)] = m.group(3)
return mons
def extract_mons_from_kubeapi():
kubemap = subprocess.check_output(kubectl_command, shell=True) # nosec
kubemap = subprocess.check_output(kubectl_command, shell=True).decode('utf-8') # nosec
return json.loads(kubemap)
current_mons = extract_mons_from_monmap()

View File

@ -28,7 +28,7 @@ function check_mon_msgr2 {
function watch_mon_health {
while [ true ]; do
echo "checking for zombie mons"
/tmp/moncheck-reap-zombies.py || true
python3 /tmp/moncheck-reap-zombies.py || true
echo "checking for ceph-mon msgr v2"
check_mon_msgr2
echo "sleep 30 sec"

View File

@ -11,4 +11,5 @@ ceph-mon:
- 0.1.8 Use full image ref for docker official images
- 0.1.9 Remove unnecessary parameters for ceph-mon
- 0.1.10 Export crash dumps when Ceph daemons crash
- 0.1.11 Correct mon-check executing binary and logic
...