blob: 3b6f8e810b71d77e100f0b65c00624118b793f7c [file] [log] [blame]
Mohammed Naserf3f59a72023-01-15 21:02:04 -05001#!/bin/bash
2
3{{/*
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/}}
16
17set -ex
18
19{{- if .Values.jobs.cell_setup.extended_wait.enabled }}
20iteration={{ .Values.jobs.cell_setup.extended_wait.iteration }}
21duration={{ .Values.jobs.cell_setup.extended_wait.duration }}
22extra_wait=true
23# Init for case wait_for_computes is not enabled. It'll have
24# the same effect as the original code that checks for at
25# least one compute is registered
26expected_computes=1
27
28if [[ -f /tmp/compute_nodes.txt ]]
29then
30 expected_computes=$(cat /tmp/compute_nodes.txt | wc -w)
31fi
32
33while [[ "$extra_wait" == true ]]
34do
35 nova_computes=$(openstack compute service list --service nova-compute -f value -c State)
36
37 if [[ -z "$(echo $nova_computes | grep down)" ]]
38 then
39 # No more down. Although all present computes are up,
40 # the number of present computes may not be the total
41 # expected number of computes as some of the remaining
42 # computes may take a bit longer to register/join.
43 actual_computes=$(echo $nova_computes | wc -w)
44 if [[ "$actual_computes" -ge "$expected_computes" ]]
45 then
46 # All expected nodes are up
47 extra_wait=false
48 fi
49 fi
50
51 if [[ "$extra_wait" == true ]]
52 then
53 sleep "$duration"
54
55 if [[ "$iteration" -gt 1 ]]
56 then
57 ((iteration=iteration-1))
58 else
59 extra_wait=false
60
61 # List out the info to see whether any nodes is still down
62 openstack compute service list --service nova-compute
63 fi
64 fi
65done
66{{- end }}
67
68until openstack compute service list --service nova-compute -f value -c State | grep -q "^up$" ;do
69 echo "Waiting for Nova Compute processes to register"
70 sleep 10
71done
Oleksandr K.24c88fd2024-12-08 22:28:50 -080072
73{{- if .Values.jobs.cell_setup.extra_command }}
74{{ .Values.jobs.cell_setup.extra_command }}
75{{- end }}