File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
code-interpreter/app/services Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -81,9 +81,33 @@ def __init__(self) -> None:
8181 self .service_account = KUBERNETES_EXECUTOR_SERVICE_ACCOUNT
8282
8383 def check_health (self ) -> HealthCheck :
84- """Verify Kubernetes API is reachable and the namespace is accessible ."""
84+ """Verify Kubernetes API is reachable and we can create pods in the namespace ."""
8585 try :
86- self .v1 .read_namespace (name = self .namespace )
86+ auth_api = client .AuthorizationV1Api ()
87+ review = auth_api .create_self_subject_access_review (
88+ body = client .V1SelfSubjectAccessReview (
89+ spec = client .V1SelfSubjectAccessReviewSpec (
90+ resource_attributes = client .V1ResourceAttributes (
91+ namespace = self .namespace ,
92+ verb = "create" ,
93+ resource = "pods" ,
94+ )
95+ )
96+ )
97+ )
98+ if not review .status .allowed :
99+ reason = review .status .reason or "no reason provided"
100+ logger .warning (
101+ f"Health check failed: cannot create pods in namespace={ self .namespace } "
102+ f"(reason={ reason } )"
103+ )
104+ return HealthCheck (
105+ status = "error" ,
106+ message = (
107+ "Service account lacks permission to create "
108+ f"pods in namespace={ self .namespace } "
109+ ),
110+ )
87111 except ApiException as e :
88112 return HealthCheck (
89113 status = "error" ,
You can’t perform that action at this time.
0 commit comments