CI: stop using fragile wait script
@@ -76,67 +76,4 @@ print("\n %s\n" % ' '.join(map(pipes.quote, cmd)))
check_call(cmd)
-
-# wait for deployment to be running via kube API
-
-config.load_kube_config()
-kube = client.CoreV1Api()
-
-def wait_for(f, msg, timeout=120):
- """Wait for f() to return True"""
- print(f"Waiting until {msg}")
- for i in range(int(timeout)):
- if f():
- break
- time.sleep(1)
- else:
- raise TimeoutError(f"{msg} did not occur in {timeout} seconds")
- print(msg)
-
-def pods_ready():
- """
- Return whether all pods in our test namespace are ready, which is a tougher
- criteria than running.
-
- ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions
- ref: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#podstatus-v1-core
- """
- pods = kube.list_namespaced_pod(namespace).items
-
- # FIXME: we could perhaps delegate this waiting for readiness to kubernetes
- # api and do like in z2jh:
- # https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/5703a8de9017d83242f8d4dd1ac00887c162629b/dev#L261-L266
- all_pods_ready = True
- for pod in pods:
- if not any(
- condition.type == "Ready" and condition.status == "True"
- for condition in pod.status.conditions
- ):
- all_pods_ready = False
- print(f"{pod.status.phase}\t{pod.metadata.name}")
- return all_pods_ready
-
-# wait until all of our pods are running and ready
-try:
- wait_for(pods_ready, "Hub is up")
-except TimeoutError:
- # show pods on timeout, in case there's a hint about what's wrong
- check_call(['kubectl', 'get', 'pod', '--all-namespaces'])
- not_running_pods = check_output([
- 'kubectl', 'get', 'pods',
- '--no-headers',
- f'--namespace={namespace}'
- '--field-selector=status.phase!=Running',
- '--output=jsonpath={.items[*].metadata.name}',
- ], text=True)
- not_running_pods = list(filter(None, not_running_pods.split(" ")))
-
- # try print logs of not running pods
- for not_running_pod in not_running_pods:
- print()
- print(f"Logs for not running pod: {not_running_pod}")
- check_call(['kubectl', 'logs', f'--namespace={namespace}', not_running_pod])
-
- raise
-
os.remove(jupyterhub_values_yaml)
