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