diff --git a/jhub/01-create-cluster.nu b/jhub/01-create-cluster.nu index c3fd3bf..96d429c 100644 --- a/jhub/01-create-cluster.nu +++ b/jhub/01-create-cluster.nu @@ -28,20 +28,25 @@ print $"[ INFO ] Creating cluster: ($cluster.name)" # Wait for cluster creation, or error on timeout let timeout = 20min let start = date now -let check_status = {|| (openstack coe cluster show $cluster.name -f yaml | from yaml).status } +let check_status = {|| + (openstack coe cluster show $cluster.name -f yaml | from yaml).status +} + mut ready = false -mut status = null +mut status: string = "" print $"[ INFO ] Waiting for cluster creation with timeout ($timeout)" while not $ready and ((date now) - $start) < $timeout { $status = do $check_status $ready = $status == "CREATE_COMPLETE" - if status == "CREATE_FAILED" { - print "[ ERROR ] Cluster creation failed!"; + + if $status == "CREATE_FAILED" { + print "[ ERROR ] Cluster creation failed!" break } - print $"[ INFO ] Time elapsed ((date now) - $start)" + + print $"[ INFO ] Status: ($status); time elapsed: ((date now) - $start)" sleep 30sec } diff --git a/jhub/06-create-nodegroup.nu b/jhub/06-create-nodegroup.nu index d081b62..7a91589 100644 --- a/jhub/06-create-nodegroup.nu +++ b/jhub/06-create-nodegroup.nu @@ -23,24 +23,29 @@ print $"[ INFO ] Creating nodegroup ($nodegroup.name)" # Wait for nodegroup creation, or error on timeout let timeout = 10min let start = date now -let check_status = {|| (openstack coe nodegroup show $cluster_name $nodegroup.name -f yaml | from yaml).status } +let check_status = {|| + (openstack coe nodegroup show $cluster_name $nodegroup.name -f yaml | from yaml).status +} + mut ready = false -mut status = null +mut status: string = "" print $"[ INFO ] Wait for nodegroup creation with timeout ($timeout)" while not $ready and ((date now) - $start) < $timeout { $status = do $check_status $ready = $status == "CREATE_COMPLETE" + if $status == "CREATE_FAILED" { - print "[ ERROR ] Nodegroup creation failed!"; + print "[ ERROR ] Nodegroup creation failed!" break } - print $"[ INFO ] Time elapsed: ((date now) - $start)" + + print $"[ INFO ] Status: ($status); time elapsed: ((date now) - $start)" sleep 30sec } if not $ready { - print $"[ [ ERROR ] Failed to create healthy nodegroup in ($timeout)" + print $"[ ERROR ] Failed to create healthy nodegroup in ($timeout)" exit 1 } diff --git a/jhub/teardown.nu b/jhub/teardown.nu index cbf6c87..c69ed14 100644 --- a/jhub/teardown.nu +++ b/jhub/teardown.nu @@ -26,7 +26,7 @@ def main [ let values_nfs = $env.jupyterhub.shared_volume.values_path let home_volume_id = (open $values_nfs | get -o openstack.volumeId) - def run [cmd: string, dry_run: bool] { + def run-cmd [cmd: string, dry_run: bool] { if $dry_run { print $"[ DRY RUN ] ($cmd)" } else { @@ -71,20 +71,20 @@ def main [ print $"[ INFO ] Cluster: ($cluster)" print $"[ INFO ] DNS record: ($fqdn)" - run "kubectl get pv -A | tail -n +2 | cut -f 1 -d ' ' > /tmp/pv.out" $dry_run - run "openstack volume list | grep -f /tmp/pv.out || true" $dry_run + run-cmd "kubectl get pv -A | tail -n +2 | cut -f 1 -d ' ' > /tmp/pv.out" $dry_run + run-cmd "openstack volume list | grep -f /tmp/pv.out || true" $dry_run - run $"openstack coe cluster delete ($cluster)" $dry_run + run-cmd $"openstack coe cluster delete ($cluster)" $dry_run wait-for-cluster-delete $cluster $dry_run $timeout print $"[ INFO ] After cluster deletion completes for ($cluster), verify PV-backed volumes:" - run "openstack volume list | grep -f /tmp/pv.out || true" $dry_run + run-cmd "openstack volume list | grep -f /tmp/pv.out || true" $dry_run - run $"openstack recordset delete ($zone) ($fqdn)" $dry_run + run-cmd $"openstack recordset delete ($zone) ($fqdn)" $dry_run if $home_volume_id != null { if $delete_home_volume { - run $"openstack volume delete ($home_volume_id)" $dry_run + run-cmd $"openstack volume delete ($home_volume_id)" $dry_run } else { print $"[ WARN ] Preserving home NFS volume: ($home_volume_id)" print $"[ INFO ] Delete manually with: openstack volume delete ($home_volume_id)"