def _GetPodNames(pod_name_prefix, job_name=None):
"""Get pod names based on the pod_name_prefix and job_name.
Args:
pod_name_prefix: value of 'name-prefix' selector.
job_name: value of 'job' selector. If None, pod names will be
selected only based on 'name-prefix' selector.
Returns:
List of pod names.
"""
pod_list_command = [
_KUBECTL, 'get', 'pods', '-o', 'name', '-a',
'-l', _GetJobSelector(pod_name_prefix, job_name)]
logging.info('Command to get pod names: %s', ' '.join(pod_list_command))
output = subprocess.check_output(pod_list_command, universal_newlines=True)
pod_names = [name for name in output.strip().split('\n') if name]
logging.info('Pod names: "%s"', ','.join(pod_names))
return pod_names
评论列表
文章目录