Skip to content
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
15 changes: 10 additions & 5 deletions jhub/01-create-cluster.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 10 additions & 5 deletions jhub/06-create-nodegroup.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
14 changes: 7 additions & 7 deletions jhub/teardown.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)"
Expand Down
Loading