diff --git a/.deploy.gitlab-ci.yml b/.deploy.gitlab-ci.yml index 2e4bd33131edb2c0838dfa600b85f8d1c5e560c9..c44c0c987e197c883b535998de6e9bfdc44f6ba4 100644 --- a/.deploy.gitlab-ci.yml +++ b/.deploy.gitlab-ci.yml @@ -7,8 +7,6 @@ stages: deploy_nomad: stage: deploy - rules: - - if: $STATION != "" needs: - pipeline: $PARENT_PIPELINE_ID job: render_levant @@ -31,3 +29,30 @@ deploy_nomad: echo "Running station ${STATION} component ${COMPONENT}" nomad job run -address="http://${HOSTNAME}:4646" jobs/${STATION}/${COMPONENT}.nomad done + +deploy_CDB: + stage: deploy + needs: + - pipeline: $PARENT_PIPELINE_ID + job: render_CDB + image: + name: hashicorp/nomad + entrypoint: [ "" ] + script: + - | + RENDER_CDB_JOB_ID=`cat generated/render-cdb-job-id.txt` + echo "render-cdb job ID: ${RENDER_CDB_JOB_ID}" + + CDB_JSON_URL="${CI_PROJECT_URL}/-/jobs/${RENDER_CDB_JOB_ID}/artifacts/raw/generated/CDB/deploy/${STATION}.json?inline=false" + + echo "Artifact URL: ${CDB_JSON_URL}" + + if [ "${STATION}" == "dts-lab" ]; then + # dts-lab test station + HOSTNAME="dts-lab.lofar.net" + else + # core/remote station + HOSTNAME="${STATION}c.control.lofar" + fi + + nomad job dispatch -address="http://${HOSTNAME}:4646" dsconfig -meta cdb_json_url="${CDB_JSON_URL}" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f16f8d1467d86ab259f34edbe4e0c7e89a241b7..d329940266110bc51373e3115c6598e1f11dc37e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -160,6 +160,8 @@ render_CDB: mkdir -p generated/CDB/deploy + echo "${CI_JOB_ID}" > ${CI_PROJECT_DIR}/generated/render-cdb-job-id.txt + cd CDB/ for STATION in ${LOFAR2_STATIONS}; do @@ -182,7 +184,7 @@ render_CDB: expose_as: 'deployment cdb configs' name: deploy-cdb paths: - - generated/CDB/deploy/ + - generated/ # Collect services from this repo, to deploy as Nomad jobs on a station render_levant: diff --git a/infra/jobs/station/dsconfig.levant.nomad b/infra/jobs/station/dsconfig.levant.nomad index 238c94be72cf6b272d2a3ec2f3f50ec5a23eb53f..ebb5c4f3f7d8f2918ed371e06c9c75935e04d3dc 100644 --- a/infra/jobs/station/dsconfig.levant.nomad +++ b/infra/jobs/station/dsconfig.levant.nomad @@ -15,6 +15,20 @@ job "dsconfig" { mode = "bridge" } + task "wait-for-db" { + lifecycle { + hook = "prestart" + sidecar = false + } + driver = "docker" + + config { + image = "[[ $.registry.astron.url ]]/busybox:latest" + command = "sh" + args = ["-c", "while ! nc -z tango.service.consul 10000; do sleep 1; done"] + } + } + task "dsconfig" { driver = "docker"