Skip to content

Commit 00520e3

Browse files
authored
Switch the Kubernetes client call to read_namespaced_pod_status() to read_namespaced_pod(), which is functionally the same but requires fewer permissions. (#3487)
Switch the Kubernetes client call to read_namespaced_pod_status() to read_namespaced_pod(), which is functionally the same but requires fewer permissions This change is based on the comment kubernetes-client/python#993 (comment). Similar to the user in the reporter of that issue, I was seeing forbidden permission when making the read_namespaced_pod_status() call, and according to the discussion there, this can be fixed by using read_namespaced_pod() instead which is almost exactly the same request/response (except the metadata.selfLink field, which is not used by the parsl code). It seems that the read_namespaced_pod_status() call requires an additional permission on "pods/status", while read_namespaced_pod() does not (I didn't check but I can only assume the latter is using permissions on the pod itself that other parts of the parsl code likely would require as well). For Google Kubernetes Engine in particular, the predefined "Kubernetes Engine Developer" IAM role grants sufficient permissions for read_namespaced_pod() and everything else needed by parsl but not for read_namespaced_pod_status().
1 parent 943079c commit 00520e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

parsl/providers/kubernetes/kube.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ def _status(self):
243243
for jid in to_poll_job_ids:
244244
phase = None
245245
try:
246-
pod_status = self.kube_client.read_namespaced_pod_status(name=jid, namespace=self.namespace)
246+
pod = self.kube_client.read_namespaced_pod(name=jid, namespace=self.namespace)
247247
except Exception:
248248
logger.exception("Failed to poll pod {} status, most likely because pod was terminated".format(jid))
249249
if self.resources[jid]['status'] is JobStatus(JobState.RUNNING):
250250
phase = 'Unknown'
251251
else:
252-
phase = pod_status.status.phase
252+
phase = pod.status.phase
253253
if phase:
254254
status = translate_table.get(phase, JobState.UNKNOWN)
255255
logger.debug("Updating pod {} with status {} to parsl status {}".format(jid,

0 commit comments

Comments
 (0)