get_pod_name: Only return running pods
get_pod_name was observed to return a list of all pods satisfying the query without consideration of the state of the pod. In one observed scenario the name of a runing pod and an terminating pod were returned. All subsequent commands used the podname with out checking for multiple entries. They clearly expect only a single name, not multiple. Modify get_pod_name to only return a single rinning pod name. Closes-bug: 2015885 Signed-off-by: Scott Little <scott.little@windriver.com> Change-Id: I0b7bf22c4481fc4a81012fc14ac9d388afd6b065
This commit is contained in:
parent
b875514efc
commit
ae18863a34
@ -60,7 +60,7 @@ class KubeHelper:
|
|||||||
selector = 'app.kubernetes.io/instance=%s,app.kubernetes.io/name=%s' \
|
selector = 'app.kubernetes.io/instance=%s,app.kubernetes.io/name=%s' \
|
||||||
% (self.config.project_name, 'stx-' + dockername)
|
% (self.config.project_name, 'stx-' + dockername)
|
||||||
cmd = self.config.kubectl() + f" get pods --selector '{selector}'" + \
|
cmd = self.config.kubectl() + f" get pods --selector '{selector}'" + \
|
||||||
" | tail -n +2 | awk '{print $1}'"
|
" | awk '$3 == \"Running\" {print $1}' | tail -n 1"
|
||||||
logger.info('Running: %s', cmd)
|
logger.info('Running: %s', cmd)
|
||||||
output = subprocess.check_output(cmd, shell=True)
|
output = subprocess.check_output(cmd, shell=True)
|
||||||
podname = str(output.decode('utf8').strip())
|
podname = str(output.decode('utf8').strip())
|
||||||
|
Loading…
Reference in New Issue
Block a user