Skip to content

Commit

Permalink
chore(ci): wait for variable time, 900s due to slow arm website (#1896)
Browse files Browse the repository at this point in the history
- Add `k3d version` to E2E to ease finding out which k3s version we're running
  • Loading branch information
corneliusroemer authored May 14, 2024
1 parent c7b7775 commit 4f0eed4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
30 changes: 17 additions & 13 deletions .github/scripts/wait_for_pods_to_be_ready.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python3

import argparse
import json
import subprocess
import time


def main():
end_time = time.time() + 480
def main(timeout=480):
end_time = time.time() + timeout

while True:
pods = get_pods()
Expand All @@ -22,35 +23,38 @@ def main():
except KeyError as e:
print("KeyError:", e, "continuing...")

print("Sleeping for 10 seconds...")
time.sleep(10)
print("Sleeping for 5 seconds...")
time.sleep(5)


def get_pods():
cmd = ['kubectl', 'get', 'pods', '-l', 'app=loculus', '-o', 'json']
cmd = ["kubectl", "get", "pods", "-l", "app=loculus", "-o", "json"]
result = subprocess.run(cmd, capture_output=True, text=True)
return json.loads(result.stdout)['items']
return json.loads(result.stdout)["items"]


def all_pods_are_ready(pods):
for pod in pods:
if "silo-import-cronjob" in pod['metadata']['name']:
if "silo-import-cronjob" in pod["metadata"]["name"]:
continue
print("Status of:", pod['metadata']['name'], "-", pod['status']['phase'])
if pod['status']['phase'] == 'Succeeded':
print("Status of:", pod["metadata"]["name"], "-", pod["status"]["phase"])
if pod["status"]["phase"] == "Succeeded":
continue
if has_container_that_is_not_ready(pod):
return False
return True


def has_container_that_is_not_ready(pod):
for container_status in pod['status']['containerStatuses']:
if container_status['ready'] is False:
print(container_status['name'], "is not ready")
for container_status in pod["status"]["containerStatuses"]:
if container_status["ready"] is False:
print(container_status["name"], "is not ready")
return True
return False


if __name__ == "__main__":
main()
parser = argparse.ArgumentParser(description="Wait for pods to be ready")
parser.add_argument("--timeout", type=int, default=480, help="Timeout in seconds")
args = parser.parse_args()
main(timeout=args.timeout)
6 changes: 4 additions & 2 deletions .github/workflows/e2e-k3d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
env:
ALL_BROWSERS: ${{ github.ref == 'refs/heads/main' || github.event.inputs.all_browsers && 'true' || 'false' }}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
wait_timeout: ${{ github.ref == 'refs/heads/main' && 900 || 180 }}

steps:
- name: Shorten sha
Expand All @@ -52,6 +53,7 @@ jobs:
- name: Install k3d
run: |
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
k3d version
- uses: azure/setup-helm@v4

Expand Down Expand Up @@ -141,8 +143,8 @@ jobs:
# wait-interval: 2
# # End of wait block

- name: Wait for the pods to be ready (timeout 480s)
run: ./.github/scripts/wait_for_pods_to_be_ready.py
- name: Wait for the pods to be ready
run: ./.github/scripts/wait_for_pods_to_be_ready.py --timeout ${{ env.wait_timeout }}
- name: Sleep for 10 secs
run: sleep 10
- name: Run E2E test
Expand Down

0 comments on commit 4f0eed4

Please sign in to comment.