@@ -167,36 +167,51 @@ setenv-defaults-nomadcloud() {
167
167
local profile_container_specs_file
168
168
profile_container_specs_file=" ${backend_dir} " /container-specs.json
169
169
170
- # If the most important `nomad` cli envars is present this is not a local
171
- # test, I repeat, this is not a drill =)
172
- if test -z " ${NOMAD_ADDR:- } "
170
+ if test -z " ${NOMAD_ADDR+set} "
173
171
then
172
+ # The variable is not set, not set but empty, just not set!
174
173
msg $( yellow " WARNING: Nomad address \" NOMAD_ADDR\" envar is not set" )
174
+ # TODO: New Nomad cluster:export NOMAD_ADDR=http://10.200.0.1:4646
175
175
export NOMAD_ADDR=" https://nomad.world.dev.cardano.org"
176
176
msg $( blue " INFO: Setting \" NOMAD_ADDR\" to the SRE provided address for \" Performance and Tracing\" (\" ${NOMAD_ADDR} \" )" )
177
177
else
178
+ # The variable is set and maybe empty!
179
+ msg $( blue " INFO: Nomad address \" NOMAD_ADDR\" envar is \" ${NOMAD_ADDR} \" " )
178
180
if test " ${NOMAD_ADDR} " ! = " https://nomad.world.dev.cardano.org"
179
181
then
180
182
msg $( yellow " WARNING: Nomad address \" NOMAD_ADDR\" envar is not \" https://nomad.world.dev.cardano.org\" " )
181
183
fi
182
184
fi
183
185
# The abscence of `NOMAD_NAMESPACE` or `NOMAD_TOKEN` needs confirmation
184
- if test -z " ${NOMAD_NAMESPACE:- } "
186
+ if test -z ${NOMAD_NAMESPACE+set}
185
187
then
188
+ # The variable is not set, not set but empty, just not set!
186
189
msg $( yellow " WARNING: Nomad namespace \" NOMAD_NAMESPACE\" envar is not set" )
190
+ # TODO: New Nomad cluster: export NOMAD_NAMESPACE=""
187
191
export NOMAD_NAMESPACE=" perf"
188
192
msg $( blue " INFO: Setting \" NOMAD_NAMESPACE\" to the SRE provided namespace for \" Performance and Tracing\" (\" ${NOMAD_NAMESPACE} \" )" )
189
193
else
194
+ # The variable is set and maybe empty!
195
+ msg $( blue " INFO: Nomad namespace \" NOMAD_NAMESPACE\" envar is \" ${NOMAD_NAMESPACE} \" " )
190
196
if test " ${NOMAD_NAMESPACE} " ! = " perf"
191
197
then
192
198
msg $( yellow " WARNING: Nomad namespace \" NOMAD_NAMESPACE\" envar is not \" perf\" " )
193
199
fi
194
200
fi
195
- if test -z " ${NOMAD_TOKEN:- } "
201
+ if test -z " ${NOMAD_TOKEN+set } "
196
202
then
203
+ # The variable is not set, not set but empty, just not set!
197
204
msg $( yellow " WARNING: Nomad token \" NOMAD_TOKEN\" envar is not set" )
198
- msg $( blue " INFO: Fetching a \" NOMAD_TOKEN\" from SRE provided Vault for \" Performance and Tracing\" " )
199
- export NOMAD_TOKEN=" $( wb_nomad vault world nomad-token) "
205
+ msg $( yellow " If you need to fetch a NOMAD_TOKEN for world.dev.cardano.org provide an empty string" )
206
+ else
207
+ # The variable is set and maybe empty!
208
+ if test -z " ${NOMAD_TOKEN} "
209
+ then
210
+ msg $( blue " INFO: Fetching a \" NOMAD_TOKEN\" from SRE provided Vault for \" Performance and Tracing\" " )
211
+ export NOMAD_TOKEN=" $( wb_nomad vault world nomad-token) "
212
+ else
213
+ msg $( blue " INFO: Using provided Nomad token \" NOMAD_TOKEN\" envar" )
214
+ fi
200
215
fi
201
216
# Check all the AWS S3 envars needed for the HTTP PUT request
202
217
# Using same names as the AWS CLI
@@ -284,8 +299,16 @@ allocate-run-nomadcloud() {
284
299
> " ${dir} " /nomad/nomad-job.json
285
300
fi
286
301
# The job file is "slightly" modified (jq) to suit the running environment.
287
- backend_nomad allocate-run-nomad-job-patch-namespace " ${dir} " " ${NOMAD_NAMESPACE} "
288
- backend_nomad allocate-run-nomad-job-patch-nix " ${dir} "
302
+ if test -n " ${NOMAD_NAMESPACE:- } "
303
+ then
304
+ # This sets only the global namespace, the job level namespace. Not groups!
305
+ backend_nomad allocate-run-nomad-job-patch-namespace " ${dir} " " ${NOMAD_NAMESPACE} "
306
+ else
307
+ # Empty the global namespace
308
+ backend_nomad allocate-run-nomad-job-patch-namespace " ${dir} "
309
+ fi
310
+ # Will set the flake URIs from ".installable" in container-specs.json
311
+ backend_nomad allocate-run-nomad-job-patch-nix " ${dir} "
289
312
290
313
# Set the placement info and resources accordingly
291
314
local nomad_job_name
@@ -348,12 +371,12 @@ allocate-run-nomadcloud() {
348
371
# #######################################################################
349
372
local group_constraints_array
350
373
# "perf" class nodes are the default unless the profile name contains
351
- # "cw-qa", we try to limit the usage of Nomad nodes that are not
352
- # dedicated Perf team nodes.
353
- # But also, we have to be careful that "perf" runs do not overlap. We
354
- # are making "perf" class nodes runs can't clash because service names
355
- # and resources definitions currently won't allow that to happen but
356
- # still a new "perf" run may mess up a previously running cluster.
374
+ # "cw-qa", we try to limit the usage of Nomad nodes that are not dedicated
375
+ # Perf team nodes.
376
+ # But also, we have to be careful that "perf" runs do not overlap. We are
377
+ # making sure "perf" class nodes runs can't clash because service names
378
+ # and resources definitions currently won't allow that to happen but a new
379
+ # "perf" run may still mess up a previously running cluster.
357
380
if echo " ${WB_SHELL_PROFILE} " | grep --quiet " cw-qa"
358
381
then
359
382
# Using "qa" class distinct nodes. Only "short" test allowed here.
@@ -366,29 +389,42 @@ allocate-run-nomadcloud() {
366
389
}
367
390
]
368
391
'
369
- else
392
+ elif test -n " ${NOMAD_NAMESPACE:- } "
393
+ then
370
394
# Using Performance & Tracing exclusive "perf" class distinct nodes!
371
- group_constraints_array='
372
- [
373
- {
374
- "operator": "="
375
- , "attribute": "${node.class}"
376
- , "value": "perf"
377
- }
378
- ]
379
- '
395
+ group_constraints_array=" \
396
+ [ \
397
+ { \
398
+ \" operator\" : \" =\" \
399
+ , \" attribute\" : \"\$ {node.class}\" \
400
+ , \" value\" : \" ${NOMAD_NAMESPACE} \" \
401
+ } \
402
+ ] \
403
+ "
404
+ fi
405
+ # It there something to change related to group constraints ?
406
+ # Sets or deletes all groups level constraints.
407
+ if test -n " ${group_constraints_array:- } "
408
+ then
409
+ # Adds it as a group level contraint to all groups.
410
+ jq \
411
+ --argjson group_constraints_array " ${group_constraints_array} " \
412
+ " .[\" job\" ][\" ${nomad_job_name} \" ][\" group\" ] |= with_entries(.value.constraint = \$ group_constraints_array)" \
413
+ " ${dir} " /nomad/nomad-job.json \
414
+ | \
415
+ sponge " ${dir} " /nomad/nomad-job.json
416
+ else
417
+ # Else, empties all group level constraints, like previous namespaces.
418
+ jq \
419
+ " .[\" job\" ][\" ${nomad_job_name} \" ][\" group\" ] |= with_entries(.value.constraint = null)" \
420
+ " ${dir} " /nomad/nomad-job.json \
421
+ | \
422
+ sponge " ${dir} " /nomad/nomad-job.json
380
423
fi
381
- # Adds it as a group level contraint.
382
- jq \
383
- --argjson group_constraints_array " ${group_constraints_array} " \
384
- " .[\" job\" ][\" ${nomad_job_name} \" ][\" group\" ] |= with_entries(.value.constraint = \$ group_constraints_array)" \
385
- " ${dir} " /nomad/nomad-job.json \
386
- | \
387
- sponge " ${dir} " /nomad/nomad-job.json
388
424
# #######################################################################
389
425
# Memory/resources: ####################################################
390
426
# #######################################################################
391
- # Set the resources, only for perf!
427
+ # Set the resources, only for perf exlusive cloud runs !
392
428
# When not "perf", when "cw-qa", only "short" tests are allowed on
393
429
# whatever resources we are given.
394
430
if echo " ${WB_SHELL_PROFILE} " | grep --quiet " cw-perf"
0 commit comments