From 079290ad38832d6a0497b47d9ea584780962a3d9 Mon Sep 17 00:00:00 2001 From: Artur Korzeniewski Date: Fri, 3 Nov 2017 14:10:40 +0100 Subject: [PATCH] Ceph: check zombie mons fix The template in kubect command was not properly formatted. Also CLUSTER to NAMESPACE env changed. Change-Id: I12fd925f30c763d9620b3889c3007496d2438f0c --- ceph/templates/bin/_check_zombie_mons.py.tpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ceph/templates/bin/_check_zombie_mons.py.tpl b/ceph/templates/bin/_check_zombie_mons.py.tpl index ca49b681bc..546f20c1fd 100644 --- a/ceph/templates/bin/_check_zombie_mons.py.tpl +++ b/ceph/templates/bin/_check_zombie_mons.py.tpl @@ -5,13 +5,13 @@ import subprocess import json MON_REGEX = r"^\d: ([0-9\.]*):\d+/\d* mon.([^ ]*)$" -# kubctl_command = 'kubectl get pods --namespace=${NAMESPACE} -l component=mon -l application=ceph -o template --template="{ {{"}}"}}range .items{{"}}"}} \\"{{"}}"}}.metadata.name{{"}}"}}\\": \\"{{"}}"}}.status.podIP{{"}}"}}\\" , {{"}}"}}end{{"}}"}} }"' +# 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 -l application=ceph -o template --template="{ {{"}}"}}range \$i, \$v := .items{{"}}"}} {{"}}"}} if \$i{{"}}"}} , {{"}}"}} end {{"}}"}} \\"{{"}}"}}\$v.spec.nodeName{{"}}"}}\\": \\"{{"}}"}}\$v.status.podIP{{"}}"}}\\" {{"}}"}}end{{"}}"}} }"' + 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{{"}}"}} }"' else: - kubectl_command = 'kubectl get pods --namespace=${NAMESPACE} -l component=mon -l application=ceph -o template --template="{ {{"}}"}}range \$i, \$v := .items{{"}}"}} {{"}}"}} if \$i{{"}}"}} , {{"}}"}} end {{"}}"}} \\"{{"}}"}}\$v.metadata.name{{"}}"}}\\": \\"{{"}}"}}\$v.status.podIP{{"}}"}}\\" {{"}}"}}end{{"}}"}} }"' + kubectl_command = 'kubectl get pods --namespace=${NAMESPACE} -l component=mon,application=ceph -o template --template="{ {{"{{"}}range \$i, \$v := .items{{"}}"}} {{"{{"}} if \$i{{"}}"}} , {{"{{"}} end {{"}}"}} \\"{{"{{"}}\$v.metadata.name{{"}}"}}\\": \\"{{"{{"}}\$v.status.podIP{{"}}"}}\\" {{"{{"}}end{{"}}"}} }"' -monmap_command = "ceph --cluster=${CLUSTER} mon getmap > /tmp/monmap && monmaptool -f /tmp/monmap --print" +monmap_command = "ceph --cluster=${NAMESPACE} mon getmap > /tmp/monmap && monmaptool -f /tmp/monmap --print" def extract_mons_from_monmap(): @@ -37,11 +37,11 @@ for mon in current_mons: removed_mon = False if not mon in expected_mons: print "removing zombie mon ", mon - subprocess.call(["ceph", "--cluster", os.environ["CLUSTER"], "mon", "remove", mon]) + subprocess.call(["ceph", "--cluster", os.environ["NAMESPACE"], "mon", "remove", mon]) removed_mon = True elif current_mons[mon] != expected_mons[mon]: # check if for some reason the ip of the mon changed print "ip change dedected for pod ", mon - subprocess.call(["kubectl", "--namespace", os.environ["CLUSTER"], "delete", "pod", mon]) + subprocess.call(["kubectl", "--namespace", os.environ["NAMESPACE"], "delete", "pod", mon]) removed_mon = True print "deleted mon %s via the kubernetes api" % mon