Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 2 | // ----------------------------------------------------------------------- |
Joey Armstrong | 518f357 | 2024-02-11 07:56:25 -0500 | [diff] [blame] | 3 | // Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | // ----------------------------------------------------------------------- |
| 17 | |
| 18 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 19 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 20 | String getIam(String func) { |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 21 | // Cannot rely on a stack trace due to jenkins manipulation |
| 22 | String src = 'vars/volthaStackDeploy.groovy' |
| 23 | String iam = [src, func].join('::') |
| 24 | return iam |
| 25 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 26 | |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 27 | // ----------------------------------------------------------------------- |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 28 | // Intent: Log progress message |
| 29 | // ----------------------------------------------------------------------- |
| 30 | void enter(String name) { |
| 31 | // Announce ourselves for log usability |
| 32 | String iam = getIam(name) |
| 33 | println("${iam}: ENTER") |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | // ----------------------------------------------------------------------- |
| 38 | // Intent: Log progress message |
| 39 | // ----------------------------------------------------------------------- |
| 40 | void leave(String name) { |
| 41 | // Announce ourselves for log usability |
| 42 | String iam = getIam(name) |
| 43 | println("${iam}: LEAVE") |
| 44 | return |
| 45 | } |
| 46 | |
| 47 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 48 | // Intent: |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 49 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 50 | void deployVolthaStack(Map cfg) { |
| 51 | enter('deployVolthaStack') |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 52 | |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 53 | sh(label : "Create VOLTHA Stack ${cfg.stackName}, (namespace=${cfg.volthaNamespace})", |
| 54 | script : """ |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 55 | |
| 56 | helm upgrade --install --create-namespace \ |
| 57 | -n ${cfg.volthaNamespace} ${cfg.stackName} ${cfg.volthaStackChart} \ |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 58 | --set global.stack_name=${cfg.stackName} \ |
| 59 | --set global.voltha_infra_name=voltha-infra \ |
Matteo Scandolo | 529e882 | 2021-07-21 10:20:18 -0700 | [diff] [blame] | 60 | --set voltha.onos_classic.replicas=${cfg.onosReplica} \ |
Roger Luethi | 2403ef0 | 2023-09-27 06:27:22 +0200 | [diff] [blame] | 61 | --set voltha.ingress.enabled=true \ |
Jan Klare | b478928 | 2024-11-15 13:19:10 +0100 | [diff] [blame] | 62 | --set voltha.ingress.hosts[0].host=voltha.${cfg.cluster} \ |
| 63 | --set voltha.ingress.hosts[0].paths[0]='/voltha.VolthaService/' \ |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 64 | --set global.voltha_infra_namespace=${cfg.infraNamespace} \ |
Matteo Scandolo | ed1afdd | 2021-04-02 16:25:45 -0700 | [diff] [blame] | 65 | ${cfg.extraHelmFlags} |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 66 | """) |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 67 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 68 | for (int i = 0; i < cfg.bbsimReplica; i++) { |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 69 | // NOTE we don't need to update the tag for DT |
| 70 | script { |
| 71 | sh(label : "Create config[$i]: bbsimCfg${cfg.stackId}${i}.yaml", |
| 72 | script : "rm -f $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml", |
| 73 | ) |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 74 | |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 75 | if (cfg.workflow == 'att' || cfg.workflow == 'tt') { |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 76 | int startingStag = 900 |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 77 | def serviceConfigFile = cfg.workflow // type(?) String |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 78 | if (cfg.withMacLearning && cfg.workflow == 'tt') { |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 79 | serviceConfigFile = 'tt-maclearner' |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 80 | } |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 81 | // bbsimCfg: type(?) Map |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 82 | def bbsimCfg = readYaml file: "$WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml" |
| 83 | // NOTE we assume that the only service that needs a different s_tag is the first one in the list |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 84 | bbsimCfg['servicesConfig']['services'][0]['s_tag'] = startingStag + i |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 85 | println "Using BBSim Service config ${bbsimCfg['servicesConfig']}" |
| 86 | writeYaml file: "$WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml", data: bbsimCfg |
| 87 | } else { |
| 88 | // NOTE if it's DT just copy the file over |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 89 | sh(label : 'DT install', |
| 90 | script : """ |
| 91 | cp $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml \ |
| 92 | $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml |
| 93 | """) |
| 94 | } // if (cfg) |
| 95 | } // script |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 96 | |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 97 | sh(label : "HELM: Create namespace=${cfg.volthaNamespace} bbsim${i}", |
| 98 | script : """ |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 99 | helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} ${cfg.bbsimChart} \ |
Matteo Scandolo | 0ce69f1 | 2021-05-04 08:44:53 -0700 | [diff] [blame] | 100 | --set olt_id="${cfg.stackId}${i}" \ |
| 101 | -f $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml \ |
| 102 | ${cfg.extraHelmFlags} |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 103 | """) |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 104 | } // for |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 105 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 106 | leave('deployVolthaStack') |
| 107 | return |
| 108 | } |
Matteo Scandolo | 937f479 | 2021-09-24 11:05:52 -0700 | [diff] [blame] | 109 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 110 | // ----------------------------------------------------------------------- |
| 111 | // Intent: Wait until the pod completed, meaning ONOS fully deployed |
| 112 | // ----------------------------------------------------------------------- |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 113 | // Todo: Move logic like this into a standalone script. |
| 114 | // Use jenkins stash or native JJB logic to publish out to nodes. |
| 115 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 116 | void launchVolthaStack(Map cfg) { |
| 117 | enter('launchVolthaStack') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 118 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 119 | /* ----------------------------------------------------------------------- |
| 120 | * % kubectl get pods |
| 121 | 17:40:15 bbsim0-868479698c-z66mk 0/1 ContainerCreating 0 6s |
| 122 | 17:40:15 voltha-voltha-adapter-openolt-68c84bf786-z98rh 0/1 Running 0 8s |
| 123 | |
| 124 | * % kubectl port-forward --address 0.0.0.0 |
| 125 | 17:40:15 error: unable to forward port because pod is not running. Current status=Pending |
| 126 | * ----------------------------------------------------------------------- |
| 127 | */ |
| 128 | sh(label : "Wait for VOLTHA Stack (stack=${cfg.stackName}, namespace=${cfg.volthaNamespace}) to start", |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 129 | script : """ |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 130 | |
| 131 | cat <<EOM |
| 132 | |
| 133 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 134 | ** Wait for VOLTHA Stack (stack=${cfg.stackName}, namespace=${cfg.volthaNamespace}) to start |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 135 | ** ----------------------------------------------------------------------- |
| 136 | EOM |
| 137 | |
| 138 | # set -euo pipefail |
Joey Armstrong | 7f6c2c0 | 2024-02-11 14:15:24 -0500 | [diff] [blame] | 139 | set +x # # Logs are noisy with set -x |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 140 | |
| 141 | declare -i count=0 |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 142 | declare -i debug=1 # uncomment to enable debugging |
| 143 | # declare -i verbose=1 # uncomment to enable debugging |
Joey Armstrong | 8da0894 | 2023-09-14 13:52:49 -0400 | [diff] [blame] | 144 | vsd_log='volthaStackDeploy.tmp' |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 145 | echo > \$vsd_log |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 146 | |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 147 | declare -i rc=0 # exit status |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 148 | while true; do |
| 149 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 150 | # Gather |
| 151 | kubectl get pods -n ${cfg.volthaNamespace} \ |
| 152 | -l app.kubernetes.io/part-of=voltha --no-headers \ |
| 153 | > \$vsd_log |
| 154 | |
| 155 | count=\$((\$count - 1)) |
| 156 | |
| 157 | # Display activity every iteration ? |
| 158 | [[ -v verbose ]] && { count=0; } |
| 159 | |
| 160 | # Display activity every minute or so {sleep(5) x count=10} |
| 161 | if [[ \$count -lt 1 ]]; then |
| 162 | count=10 |
| 163 | cat \$vsd_log |
| 164 | fi |
| 165 | |
| 166 | ## ----------------------- |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 167 | ## Probe for cluster state |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 168 | ## ----------------------- |
| 169 | if grep -q -e 'ContainerCreating' \$vsd_log; then |
Jan Klare | 415f3b7 | 2023-10-25 09:23:15 +0200 | [diff] [blame] | 170 | echo -e '\nvolthaStackDeploy.groovy: ContainerCreating active' |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 171 | [[ -v debug ]] && grep -e 'ContainerCreating' \$vsd_log |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 172 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 173 | elif grep -q -e '0/' \$vsd_log; then |
| 174 | echo -e '\nvolthaStackDeploy.groovy: Waiting for status=Running' |
| 175 | [[ -v debug ]] && grep -e '0/' \$vsd_log |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 176 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 177 | elif ! grep -q '/' \$vsd_log; then |
| 178 | echo -e '\nvolthaStackDeploy.groovy: Waiting for initial pod activity' |
| 179 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 180 | |
| 181 | # ----------------------------------------------------------------------- |
| 182 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 CrashLoopBackOff 2 69s |
| 183 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 Error 3 85s |
| 184 | # ----------------------------------------------------------------------- |
| 185 | elif grep -q 'Error' \$vsd_log; then |
| 186 | echo -e '\nvolthaStackDeploy.groovy: Detected cluster state=Error' |
| 187 | cat \$vsd_log |
| 188 | rc=1 # fatal |
| 189 | break |
| 190 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 191 | # ----------------------------------------------------------------------- |
| 192 | # An extra conditon needed here but shell coding is tricky: |
| 193 | # "svc x/y Running 0 6s |
| 194 | # Verify (x == y) && (x > 0) |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 195 | # Wait until job failure/we have an actual need for it. |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 196 | # ----------------------------------------------------------------------- |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 197 | # Could check for all services 'Running', is that reliable (?) |
| 198 | # ----------------------------------------------------------------------- |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 199 | else |
| 200 | echo -e '\nvolthaStackDeploy.groovy: Voltha stack has launched' |
| 201 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 202 | break |
| 203 | fi |
| 204 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 205 | ## Support argument --timeout (?) |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 206 | sleep 5 |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 207 | |
| 208 | done |
| 209 | rm -f \$vsd_log |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 210 | exit \$rc |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 211 | """) |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 212 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 213 | leave('launchVolthaStack') |
| 214 | return |
| 215 | } |
| 216 | |
| 217 | // ----------------------------------------------------------------------- |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 218 | // Intent: Wait until the pod completed, meaning ONOS fully deployed |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 219 | // ----------------------------------------------------------------------- |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 220 | void waitForOnosDeploy(Map cfg) { |
| 221 | enter('waitForOnosDeploy') |
| 222 | |
| 223 | sh(label : 'Wait for ONOS full deployment', |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 224 | script : """ |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 225 | |
| 226 | cat <<EOM |
| 227 | |
| 228 | ** ----------------------------------------------------------------------- |
| 229 | ** Wait for ONOS full deployment |
| 230 | ** ----------------------------------------------------------------------- |
| 231 | EOM |
| 232 | |
| 233 | # set -euo pipefail |
| 234 | set +x # # Noisy when commented (default: uncommented) |
| 235 | |
| 236 | declare -i count=0 |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 237 | declare -i debug=1 # uncomment to enable debugging |
Joey Armstrong | 7f6c2c0 | 2024-02-11 14:15:24 -0500 | [diff] [blame] | 238 | declare -i verbose=1 # uncomment to enable debugging |
Joey Armstrong | 8da0894 | 2023-09-14 13:52:49 -0400 | [diff] [blame] | 239 | vsd_log='volthaStackDeploy.tmp' |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 240 | echo > \$vsd_log |
| 241 | |
| 242 | declare -i rc=0 # exit status |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 243 | while true; do |
| 244 | |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 245 | # Gather -- should we check for count(svc > 1) ? |
| 246 | kubectl get pods -l app=onos-config-loader \ |
| 247 | -n ${cfg.infraNamespace} --no-headers \ |
| 248 | --field-selector=status.phase=Running \ |
| 249 | > \$vsd_log |
| 250 | |
| 251 | count=\$((\$count - 1)) |
| 252 | |
| 253 | # Display activity every iteration ? |
| 254 | [[ -v verbose ]] && { count=0; } |
| 255 | |
| 256 | # Display activity every minute or so {sleep(5) x count=10} |
| 257 | if [[ \$count -lt 1 ]]; then |
| 258 | count=10 |
| 259 | cat \$vsd_log |
| 260 | fi |
| 261 | |
| 262 | ## ----------------------- |
| 263 | ## Probe for cluster state |
| 264 | ## ----------------------- |
| 265 | if grep -q -e 'ContainerCreating' \$vsd_log; then |
Jan Klare | 415f3b7 | 2023-10-25 09:23:15 +0200 | [diff] [blame] | 266 | echo -e '\nvolthaStackDeploy.groovy: ContainerCreating active' |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 267 | [[ -v debug ]] && grep -e 'ContainerCreating' \$vsd_log |
| 268 | |
| 269 | elif grep -q -e '0/' \$vsd_log; then |
| 270 | echo -e '\nvolthaStackDeploy.groovy: Waiting for status=Running' |
| 271 | [[ -v debug ]] && grep -e '0/' \$vsd_log |
| 272 | |
| 273 | elif ! grep -q '/' \$vsd_log; then |
| 274 | echo -e '\nvolthaStackDeploy.groovy: Waiting for initial pod activity' |
| 275 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
| 276 | |
| 277 | # ----------------------------------------------------------------------- |
| 278 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 CrashLoopBackOff 2 69s |
| 279 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 Error 3 85s |
| 280 | # ----------------------------------------------------------------------- |
| 281 | elif grep -q 'Error' \$vsd_log; then |
| 282 | echo -e '\nvolthaStackDeploy.groovy: Detected cluster state=Error' |
| 283 | cat \$vsd_log |
| 284 | rc=1 # fatal |
| 285 | break |
| 286 | |
| 287 | # ----------------------------------------------------------------------- |
| 288 | # An extra conditon needed here but shell coding is tricky: |
| 289 | # "svc x/y Running 0 6s |
| 290 | # Verify (x == y) && (x > 0) |
| 291 | # Wait until job failure/we have an actual need for it. |
| 292 | # ----------------------------------------------------------------------- |
| 293 | # Could check for all services 'Running', is that reliable (?) |
| 294 | # ----------------------------------------------------------------------- |
| 295 | else |
| 296 | echo -e '\nvolthaStackDeploy.groovy: Voltha stack has launched' |
| 297 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 298 | break |
| 299 | fi |
| 300 | |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 301 | ## Support argument --timeout (?) |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 302 | sleep 5 |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 303 | |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 304 | done |
| 305 | rm -f \$vsd_log |
Joey Armstrong | 8c34712 | 2023-09-18 17:04:49 -0400 | [diff] [blame] | 306 | exit \$rc |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 307 | """) |
| 308 | |
| 309 | leave('waitForOnosDeploy') |
| 310 | return |
| 311 | } |
| 312 | |
| 313 | // ----------------------------------------------------------------------- |
| 314 | // ----------------------------------------------------------------------- |
| 315 | void process(Map config) { |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 316 | enter('process') |
| 317 | |
| 318 | // note that I can't define this outside the function as there's no global scope in Groovy |
| 319 | Map defaultConfig = [ |
| 320 | bbsimReplica: 1, |
| 321 | infraNamespace: 'infra', |
| 322 | volthaNamespace: 'voltha', |
| 323 | stackName: 'voltha', |
| 324 | stackId: 1, // NOTE this is used to differentiate between BBSims across multiple stacks |
| 325 | workflow: 'att', |
| 326 | withMacLearning: false, |
| 327 | withFttb: false, |
| 328 | extraHelmFlags: '', |
| 329 | localCharts: false, |
| 330 | onosReplica: 1, |
| 331 | adaptersToWait: 2, |
Jan Klare | b478928 | 2024-11-15 13:19:10 +0100 | [diff] [blame] | 332 | cluster: 'voltha.local', |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 333 | ] |
| 334 | |
| 335 | Map cfg = defaultConfig + config |
| 336 | |
| 337 | // Augment config map |
| 338 | cfg.volthaStackChart = 'onf/voltha-stack' |
| 339 | cfg.bbsimChart = 'onf/bbsim' |
| 340 | |
| 341 | if (cfg.localCharts) { |
| 342 | cfg.volthaStackChart = "$WORKSPACE/voltha-helm-charts/voltha-stack" |
| 343 | cfg.bbsimChart = "$WORKSPACE/voltha-helm-charts/bbsim" |
| 344 | |
| 345 | sh(label : 'HELM: Update voltha-stack deps', |
| 346 | script : """ |
| 347 | pushd $WORKSPACE/voltha-helm-charts/voltha-stack |
| 348 | helm dep update |
| 349 | popd |
| 350 | """) |
| 351 | } |
| 352 | |
| 353 | println "Deploying VOLTHA Stack with the following parameters: ${cfg}." |
| 354 | deployVolthaStack(cfg) |
| 355 | launchVolthaStack(cfg) |
| 356 | waitForAdapters(cfg) |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 357 | waitForOnosDeploy(cfg) |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 358 | leave('process') |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 359 | |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 360 | return |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 361 | } |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 362 | |
| 363 | // ----------------------------------------------------------------------- |
| 364 | // ----------------------------------------------------------------------- |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 365 | def call(Map config=[:]) { // Function return type(?) |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 366 | try { |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 367 | enter('main') |
| 368 | process(config) |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 369 | } |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 370 | catch (Exception err) { // groovylint-disable-line CatchException |
| 371 | ans = false |
| 372 | println("** volthaStackDeploy.groovy: EXCEPTION ${err}") |
| 373 | throw err |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 374 | } |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 375 | finally { |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 376 | leave('main') |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 377 | } |
| 378 | return |
| 379 | } |
| 380 | |
| 381 | // [EOF] |