@@ -167,36 +167,51 @@ setenv-defaults-nomadcloud() {
167167 local profile_container_specs_file
168168 profile_container_specs_file=" ${backend_dir} " /container-specs.json
169169
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} "
173171 then
172+ # The variable is not set, not set but empty, just not set!
174173 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
175175 export NOMAD_ADDR=" https://nomad.world.dev.cardano.org"
176176 msg $( blue " INFO: Setting \" NOMAD_ADDR\" to the SRE provided address for \" Performance and Tracing\" (\" ${NOMAD_ADDR} \" )" )
177177 else
178+ # The variable is set and maybe empty!
179+ msg $( blue " INFO: Nomad address \" NOMAD_ADDR\" envar is \" ${NOMAD_ADDR} \" " )
178180 if test " ${NOMAD_ADDR} " ! = " https://nomad.world.dev.cardano.org"
179181 then
180182 msg $( yellow " WARNING: Nomad address \" NOMAD_ADDR\" envar is not \" https://nomad.world.dev.cardano.org\" " )
181183 fi
182184 fi
183185 # The abscence of `NOMAD_NAMESPACE` or `NOMAD_TOKEN` needs confirmation
184- if test -z " ${NOMAD_NAMESPACE:- } "
186+ if test -z ${NOMAD_NAMESPACE+set}
185187 then
188+ # The variable is not set, not set but empty, just not set!
186189 msg $( yellow " WARNING: Nomad namespace \" NOMAD_NAMESPACE\" envar is not set" )
190+ # TODO: New Nomad cluster: export NOMAD_NAMESPACE=""
187191 export NOMAD_NAMESPACE=" perf"
188192 msg $( blue " INFO: Setting \" NOMAD_NAMESPACE\" to the SRE provided namespace for \" Performance and Tracing\" (\" ${NOMAD_NAMESPACE} \" )" )
189193 else
194+ # The variable is set and maybe empty!
195+ msg $( blue " INFO: Nomad namespace \" NOMAD_NAMESPACE\" envar is \" ${NOMAD_NAMESPACE} \" " )
190196 if test " ${NOMAD_NAMESPACE} " ! = " perf"
191197 then
192198 msg $( yellow " WARNING: Nomad namespace \" NOMAD_NAMESPACE\" envar is not \" perf\" " )
193199 fi
194200 fi
195- if test -z " ${NOMAD_TOKEN:- } "
201+ if test -z " ${NOMAD_TOKEN+set } "
196202 then
203+ # The variable is not set, not set but empty, just not set!
197204 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
200215 fi
201216 # Check all the AWS S3 envars needed for the HTTP PUT request
202217 # Using same names as the AWS CLI
@@ -284,8 +299,16 @@ allocate-run-nomadcloud() {
284299 > " ${dir} " /nomad/nomad-job.json
285300 fi
286301 # 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} "
289312
290313 # Set the placement info and resources accordingly
291314 local nomad_job_name
@@ -348,12 +371,12 @@ allocate-run-nomadcloud() {
348371 # #######################################################################
349372 local group_constraints_array
350373 # "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.
357380 if echo " ${WB_SHELL_PROFILE} " | grep --quiet " cw-qa"
358381 then
359382 # Using "qa" class distinct nodes. Only "short" test allowed here.
@@ -366,29 +389,42 @@ allocate-run-nomadcloud() {
366389 }
367390 ]
368391 '
369- else
392+ elif test -n " ${NOMAD_NAMESPACE:- } "
393+ then
370394 # 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
380423 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
388424 # #######################################################################
389425 # Memory/resources: ####################################################
390426 # #######################################################################
391- # Set the resources, only for perf!
427+ # Set the resources, only for perf exlusive cloud runs !
392428 # When not "perf", when "cw-qa", only "short" tests are allowed on
393429 # whatever resources we are given.
394430 if echo " ${WB_SHELL_PROFILE} " | grep --quiet " cw-perf"
0 commit comments