Skip to content

Commit

Permalink
use field-selector to filter out running pods
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Sep 22, 2023
1 parent 8ec4542 commit ba3e498
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions utils/dump_logs/dump_irodscsidriver_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,23 @@

def get_kube_controller_pods(kubeconf=""):
kubepods = []
kubecommand = "kubectl get pods -n irods-csi-driver --no-headers --ignore-not-found -l app.kubernetes.io/instance=irods-csi-driver-controller" + kubeconf
kubecommand = "kubectl get pods -n irods-csi-driver --no-headers --ignore-not-found -l app.kubernetes.io/instance=irods-csi-driver-controller --field-selector status.phase=Running -o name" + kubeconf

pipe = os.popen(kubecommand)
for line in pipe:
fields = line.strip().split()
if len(fields) < 5:
continue

podname = fields[0].strip()
status = fields[2].strip()

if status == "Running":
kubepods.append(podname)
podname = line.strip()
kubepods.append(podname)

return kubepods

def get_kube_node_pods(kubeconf=""):
kubepods = []
kubecommand = "kubectl get pods -n irods-csi-driver --no-headers --ignore-not-found -l app.kubernetes.io/instance=irods-csi-driver-node" + kubeconf
kubecommand = "kubectl get pods -n irods-csi-driver --no-headers --ignore-not-found -l app.kubernetes.io/instance=irods-csi-driver-node --field-selector status.phase=Running -o name" + kubeconf

pipe = os.popen(kubecommand)
for line in pipe:
fields = line.strip().split()
if len(fields) < 5:
continue

podname = fields[0].strip()
status = fields[2].strip()

if status == "Running":
kubepods.append(podname)
podname = line.strip()
kubepods.append(podname)

return kubepods

Expand Down

0 comments on commit ba3e498

Please sign in to comment.