Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | {{/* |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */}} |
| 16 | |
| 17 | set -ex |
| 18 | |
| 19 | {{- if .Values.jobs.cell_setup.extended_wait.enabled }} |
| 20 | iteration={{ .Values.jobs.cell_setup.extended_wait.iteration }} |
| 21 | duration={{ .Values.jobs.cell_setup.extended_wait.duration }} |
| 22 | extra_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 |
| 26 | expected_computes=1 |
| 27 | |
| 28 | if [[ -f /tmp/compute_nodes.txt ]] |
| 29 | then |
| 30 | expected_computes=$(cat /tmp/compute_nodes.txt | wc -w) |
| 31 | fi |
| 32 | |
| 33 | while [[ "$extra_wait" == true ]] |
| 34 | do |
| 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 |
| 65 | done |
| 66 | {{- end }} |
| 67 | |
| 68 | until 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 |
| 71 | done |
Oleksandr K. | 24c88fd | 2024-12-08 22:28:50 -0800 | [diff] [blame] | 72 | |
| 73 | {{- if .Values.jobs.cell_setup.extra_command }} |
| 74 | {{ .Values.jobs.cell_setup.extra_command }} |
| 75 | {{- end }} |