Skip to content

Commit

Permalink
[k8s] update kr8s with latest bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgorana committed Feb 2, 2024
1 parent b67e1f5 commit 3a8b849
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/syft/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ syft =
numpy>=1.23.5,<=1.24.4
pandas==1.5.3
docker==6.1.3
kr8s==0.13.0
kr8s==0.13.1
PyYAML==6.0.1
azure-storage-blob==12.19

Expand Down
27 changes: 2 additions & 25 deletions packages/syft/src/syft/custom_worker/runner_k8s.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# stdlib
from time import sleep
from typing import Dict
from typing import List
from typing import Optional
Expand Down Expand Up @@ -56,7 +55,8 @@ def create_pool(
)

# wait for replicas to be available and ready
self.wait(deployment, available_replicas=replicas)
status_path = "{.status.availableReplicas}"
deployment.wait(f"jsonpath='{status_path}'={replicas}")
except Exception:
raise
finally:
Expand Down Expand Up @@ -116,29 +116,6 @@ def get_pod_env_vars(self, pod: Union[str, Pod]) -> Optional[List[Dict]]:
pod = KubeUtils.resolve_pod(self.client, pod)
return KubeUtils.get_pod_env(pod)

def wait(
self,
deployment: StatefulSet,
available_replicas: int,
timeout: int = 300,
) -> None:
# TODO: Report wait('jsonpath=') bug to kr8s
# Until then this is the substitute implementation

if available_replicas <= 0:
return

while True:
if timeout == 0:
raise TimeoutError("Timeout waiting for replicas")

deployment.refresh()
if deployment.status.availableReplicas == available_replicas:
break

timeout -= 1
sleep(1)

def _create_image_pull_secret(
self,
pool_name: str,
Expand Down

0 comments on commit 3a8b849

Please sign in to comment.