Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm rollout #240

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions abm/lib/helm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import time
import argparse
Expand Down Expand Up @@ -54,8 +55,8 @@ def update(context: Context, args: list):

print('Waiting for the new deployments to come online')
# Give kubernetes a moment to start processing the update.
time.sleep(30)
wait_until_ready(namespace, env)
time.sleep(5)
wait_until_ready(namespace)
return True


Expand Down Expand Up @@ -87,8 +88,7 @@ def update_cli(context: Context, args: list):

def wait(context: Context, args: list):
namespace = args[0] if len(args) > 0 else 'galaxy'
env = get_env(context)
wait_until_ready(namespace, get_env(context))
wait_until_ready(namespace) #, get_env(context))


def filter(lines:list, item:str):
Expand Down Expand Up @@ -122,16 +122,27 @@ def wait_for(kubectl:str, namespace:str, name: str, env: dict):
print(f"{name} is running")


def wait_until_ready(namespace: str, env: dict):
# def wait_until_ready(namespace: str, env: dict):
# kubectl = find_executable('kubectl')
# if kubectl is None:
# print('ERROR: kubectl is not available on the $PATH')
# return
# wait_for(kubectl, namespace, 'galaxy-job', env)
# wait_for(kubectl, namespace, 'galaxy-web', env)
# wait_for(kubectl, namespace, 'galaxy-workflow', env)
def wait_until_ready(namespace: str):
kubectl = find_executable('kubectl')
if kubectl is None:
print('ERROR: kubectl is not available on the $PATH')
return
wait_for(kubectl, namespace, 'galaxy-job', env)
wait_for(kubectl, namespace, 'galaxy-web', env)
wait_for(kubectl, namespace, 'galaxy-workflow', env)


def list(context: Context, args: list):
data = run(f"{kubectl} get deployment -n {namespace} -o json")
deployment_data = json.loads(data)
deployments = list()
for deployment in deployment_data['items']:
metadata = deployment['metadata']
name = metadata['name']
if 'job' in name or 'web' in name or 'workflow' in name:
deployments.append(name)
for deployment in deployments:
print(run(f"{kubectl} rollout status deployment -n {namespace} {deployment} --watch"))

def _list(context: Context, args: list):
print("Not implemented")

2 changes: 1 addition & 1 deletion abm/lib/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
help: wait for the deployment to come online
- name: [list, ls]
help: list some things...
handler: helm.list
handler: helm._list
- name: [kubectl, kube, k]
help: execute a kubectl command
menu:
Expand Down