diff --git a/.gitignore b/.gitignore index 8ee8430be40555ed5cf527dfb54c8e515d0ae80c..b43090811ebd52b214d4fc1ad18ef656b3c560d6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,7 @@ **/env **/pending_log_messages.db **/vscode-server.tar -.orig - -bin/jumppad +**/*.orig tangostationcontrol/build tangostationcontrol/cover @@ -37,10 +35,10 @@ deploy/hosts docker-compose/alerta-web/alerta-secrets.json docker-compose/tmp -infra/dev/jobs/*.nomad +infra/dev/jobs/station/*.nomad infra/dev/nomad/tmp/* !infra/dev/nomad/tmp/.keep **/CDB/dump*.json -bin/jumppad +.bin/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 642113392243bdad41570bdb3c7728fc0ac78f4f..35578a61156b4a3e903cb8296216778b78961746 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,8 @@ image: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG -#image: python:3.10 variables: GIT_SUBMODULE_STRATEGY: recursive PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" PIP_REQUIREMENTS_FILE: "tangostationcontrol/requirements.txt" - DOCKER_DRIVER: overlay2 - DOCKER_TLS_CERTDIR: "" cache: key: $CI_COMMIT_REF_SLUG paths: @@ -58,8 +55,6 @@ wheel_packaging: - wheel_packaging needs: - wheel_packaging - tags: - - privileged before_script: - | if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" && -z "$CI_COMMIT_TAG" ]]; then @@ -272,7 +267,7 @@ unit_test: - unit_test - docker_build_image_device_base tags: - - privileged + - integration_tests variables: JUMPPAD_HOME: $CI_PROJECT_DIR before_script: @@ -286,6 +281,7 @@ unit_test: fi - apk update - apk add git + - apk add jq - apk add --update make bash - apk add --update bind-tools - apk add --update postgresql14-client gzip socat @@ -300,6 +296,7 @@ unit_test: # TANGO_HOST must be unset our databaseds will be unreachable - unset TANGO_HOST - export TAG="$tag" + - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh pull $tag # Forward nomad API port to docker host - socat tcp-listen:4646,reuseaddr,fork tcp:docker:4646 & # Forward consul dns port to docker host @@ -308,6 +305,7 @@ unit_test: when: always paths: - log/ + - .jumppad/logs/ integration_test_docker: extends: .test_docker @@ -315,19 +313,12 @@ integration_test_docker: - echo 'DNS ${DNS}' - echo 'Network ${NETWORK_MODE}' # Do not remove 'bash' or statement will be ignored by primitive docker shell - - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh pull $tag - # re-tag alpine image from our registry to trick nomad in using it - - docker tag git.astron.nl:5000/lofar2.0/tango/alpine:latest alpine:latest - - docker pull git.astron.nl:5000/lofar2.0/tango/docker-registry-proxy:0.6.3 - - docker tag git.astron.nl:5000/lofar2.0/tango/docker-registry-proxy:0.6.3 docker-registry-proxy:0.6.3 - # Do not remove 'bash' or statement will be ignored by primitive docker shell - - bash -e $CI_PROJECT_DIR/sbin/run_integration_test.sh --no-build --save-logs + - bash -e $CI_PROJECT_DIR/sbin/run_integration_test.sh --no-build --save-logs --module="tango" service_test_docker: extends: .test_docker script: - - export HOSTNAME=localhost - # Do not remove 'bash' or statement will be ignored by primitive docker shell + # Do not remove 'bash' or statement will be ignored by primitive docker shell - bash -e $CI_PROJECT_DIR/sbin/run_service_test.sh multi_project_integration_test: diff --git a/.prepare.gitlab-ci.yml b/.prepare.gitlab-ci.yml index b58c604024448ca314dbdae58d97a21bf0c2cbf2..aba1e9d272909e9a7abd49d4da0037c12f5e7b3c 100644 --- a/.prepare.gitlab-ci.yml +++ b/.prepare.gitlab-ci.yml @@ -3,12 +3,7 @@ stages: build_ci_runner_image: stage: build - image: docker:stable - tags: - - privileged - variables: - DOCKER_DRIVER: overlay2 - DOCKER_TLS_CERTDIR: "" + image: docker:latest script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - | diff --git a/CDB/integrations/digitalbeam_cluster_ConfigDb.json b/CDB/integrations/digitalbeam_cluster_ConfigDb.json index 6648f6c59d4b02dbd7eb5532094f7a62322b252d..5066d35f0bec32f286d49e1db5aad3d646b1420e 100644 --- a/CDB/integrations/digitalbeam_cluster_ConfigDb.json +++ b/CDB/integrations/digitalbeam_cluster_ConfigDb.json @@ -9,7 +9,7 @@ "STAT/SDP/HBA0" ], "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -28,7 +28,7 @@ "STAT/SDP/HBA1" ], "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -47,7 +47,7 @@ "STAT/SDP/LBA" ], "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -69,7 +69,7 @@ "STAT/SDP/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -82,7 +82,7 @@ "STAT/SDP/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -95,7 +95,7 @@ "STAT/SDP/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -117,7 +117,7 @@ "STAT/SDP/HBA0" ], "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -205,7 +205,7 @@ "STAT/SDP/HBA1" ], "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -293,7 +293,7 @@ "STAT/SDP/LBA" ], "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -1323,7 +1323,7 @@ "STAT/RECVH/H0": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -1342,7 +1342,7 @@ "STAT/RECVL/L0": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -1355,7 +1355,7 @@ "STAT/RECVL/L1": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" diff --git a/CDB/integrations/tilebeam_cluster_ConfigDb.json b/CDB/integrations/tilebeam_cluster_ConfigDb.json index ccdc58ccb19c1c36d8c7f416555c9005f4e0b513..19e6d9cc657bb7b3b0cfdefb894dce9d5c9bbd82 100644 --- a/CDB/integrations/tilebeam_cluster_ConfigDb.json +++ b/CDB/integrations/tilebeam_cluster_ConfigDb.json @@ -482,7 +482,7 @@ "STAT/RECVH/1": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -495,7 +495,7 @@ "STAT/RECVH/2": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -508,7 +508,7 @@ "STAT/RECVH/3": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -521,7 +521,7 @@ "STAT/RECVH/4": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -540,7 +540,7 @@ "STAT/RECVL/1": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -553,7 +553,7 @@ "STAT/RECVL/2": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -566,7 +566,7 @@ "STAT/RECVL/3": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -579,7 +579,7 @@ "STAT/RECVL/4": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" diff --git a/CDB/stations/DTS.json b/CDB/stations/DTS.json index 75cff8b02f606ff35fdf32edccb609a515b8fa98..e17fb961924afd03f799c478578b40c5b94b6707 100644 --- a/CDB/stations/DTS.json +++ b/CDB/stations/DTS.json @@ -46,7 +46,7 @@ "STAT/EC/1": { "properties": { "OPC_Server_Name": [ - "ec-sim" + "ec-sim.service.consul" ] } } @@ -74,7 +74,7 @@ "STAT/CCD/1": { "properties": { "OPC_Server_Name": [ - "ccd-sim" + "ccd-sim.service.consul" ] } } diff --git a/CDB/stations/simulators_ConfigDb.json b/CDB/stations/simulators_ConfigDb.json index 6ce4102b6ae394ebbd930f03138c1a4227dc1487..8203da6e416008607dff873544688c0b4970cbe7 100644 --- a/CDB/stations/simulators_ConfigDb.json +++ b/CDB/stations/simulators_ConfigDb.json @@ -6,10 +6,10 @@ "STAT/APSCT/1": { "properties": { "OPC_Server_Name": [ - "apsct-sim" + "apsct-sim.service.consul" ], "OPC_Server_Port": [ - "4843" + "4846" ], "OPC_Time_Out": [ "5.0" @@ -25,7 +25,7 @@ "STAT/CCD/1": { "properties": { "OPC_Server_Name": [ - "ccd-sim" + "ccd-sim.service.consul" ], "OPC_Server_Port": [ "4843" @@ -44,10 +44,10 @@ "STAT/EC/1": { "properties": { "OPC_Server_Name": [ - "ec-sim" + "ec-sim.service.consul" ], "OPC_Server_Port": [ - "4840" + "4850" ], "OPC_Time_Out": [ "5.0" @@ -70,7 +70,7 @@ "STAT/APSPU/1": { "properties": { "OPC_Server_Name": [ - "apspu-sim" + "apspu-sim.service.consul" ], "OPC_Server_Port": [ "4842" @@ -89,7 +89,7 @@ "STAT/Beamlet/HBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -190,7 +190,7 @@ "STAT/RECVH/1": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -209,7 +209,7 @@ "STAT/RECVL/1": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -228,7 +228,7 @@ "STAT/SDPFirmware/HBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -247,7 +247,7 @@ "STAT/SDP/HBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -266,7 +266,7 @@ "STAT/BST/HBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -321,7 +321,7 @@ "STAT/SST/HBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -376,7 +376,7 @@ "STAT/XST/HBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -431,7 +431,7 @@ "STAT/UNB2/1": { "properties": { "OPC_Server_Name": [ - "unb2-sim" + "unb2-sim.service.consul" ], "OPC_Server_Port": [ "4841" diff --git a/CDB/stations/testenv_cs001.json b/CDB/stations/testenv_cs001.json index da4b205c396a99402dde96c116180209efdcf227..d4bab494fa2ff673a2303f25687c80c2eb42e1a6 100644 --- a/CDB/stations/testenv_cs001.json +++ b/CDB/stations/testenv_cs001.json @@ -6,10 +6,10 @@ "STAT/APSCT/L0": { "properties": { "OPC_Server_Name": [ - "apsct-sim" + "apsct-sim.service.consul" ], "OPC_Server_Port": [ - "4843" + "4846" ], "OPC_Time_Out": [ "5.0" @@ -22,10 +22,10 @@ "STAT/APSCT/L1": { "properties": { "OPC_Server_Name": [ - "apsct-sim" + "apsct-sim.service.consul" ], "OPC_Server_Port": [ - "4843" + "4846" ], "OPC_Time_Out": [ "5.0" @@ -38,10 +38,10 @@ "STAT/APSCT/H0": { "properties": { "OPC_Server_Name": [ - "apsct-sim" + "apsct-sim.service.consul" ], "OPC_Server_Port": [ - "4843" + "4846" ], "OPC_Time_Out": [ "5.0" @@ -60,7 +60,7 @@ "STAT/CCD/1": { "properties": { "OPC_Server_Name": [ - "ccd-sim" + "ccd-sim.service.consul" ], "OPC_Server_Port": [ "4843" @@ -82,10 +82,10 @@ "STAT/EC/1": { "properties": { "OPC_Server_Name": [ - "ec-sim" + "ec-sim.service.consul" ], "OPC_Server_Port": [ - "4840" + "4850" ], "OPC_Time_Out": [ "5.0" @@ -108,7 +108,7 @@ "STAT/APSPU/L0": { "properties": { "OPC_Server_Name": [ - "apspu-sim" + "apspu-sim.service.consul" ], "OPC_Server_Port": [ "4842" @@ -121,7 +121,7 @@ "STAT/APSPU/L1": { "properties": { "OPC_Server_Name": [ - "apspu-sim" + "apspu-sim.service.consul" ], "OPC_Server_Port": [ "4842" @@ -134,7 +134,7 @@ "STAT/APSPU/H0": { "properties": { "OPC_Server_Name": [ - "apspu-sim" + "apspu-sim.service.consul" ], "OPC_Server_Port": [ "4842" @@ -153,7 +153,7 @@ "STAT/Beamlet/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -202,7 +202,7 @@ "STAT/Beamlet/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -251,7 +251,7 @@ "STAT/Beamlet/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -412,7 +412,7 @@ "STAT/RECVH/H0": { "properties": { "OPC_Server_Name": [ - "recvh-sim" + "recvh-sim.service.consul" ], "OPC_Server_Port": [ "4844" @@ -437,7 +437,7 @@ "STAT/RECVL/L0": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -456,7 +456,7 @@ "STAT/RECVL/L1": { "properties": { "OPC_Server_Name": [ - "recvl-sim" + "recvl-sim.service.consul" ], "OPC_Server_Port": [ "4845" @@ -481,7 +481,7 @@ "STAT/SDPFirmware/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -497,7 +497,7 @@ "STAT/SDPFirmware/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -513,7 +513,7 @@ "STAT/SDPFirmware/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -535,7 +535,7 @@ "STAT/SDP/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -548,7 +548,7 @@ "STAT/SDP/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -561,7 +561,7 @@ "STAT/SDP/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -580,7 +580,7 @@ "STAT/BST/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -629,7 +629,7 @@ "STAT/BST/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -678,7 +678,7 @@ "STAT/BST/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -733,7 +733,7 @@ "STAT/SST/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -782,7 +782,7 @@ "STAT/SST/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -831,7 +831,7 @@ "STAT/SST/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -886,7 +886,7 @@ "STAT/XST/LBA": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -935,7 +935,7 @@ "STAT/XST/HBA0": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -984,7 +984,7 @@ "STAT/XST/HBA1": { "properties": { "OPC_Server_Name": [ - "sdptr-sim" + "sdptr-sim.service.consul" ], "OPC_Server_Port": [ "4840" @@ -1039,7 +1039,7 @@ "STAT/UNB2/L0": { "properties": { "OPC_Server_Name": [ - "unb2-sim" + "unb2-sim.service.consul" ], "OPC_Server_Port": [ "4841" @@ -1055,7 +1055,7 @@ "STAT/UNB2/L1": { "properties": { "OPC_Server_Name": [ - "unb2-sim" + "unb2-sim.service.consul" ], "OPC_Server_Port": [ "4841" @@ -1071,7 +1071,7 @@ "STAT/UNB2/H0": { "properties": { "OPC_Server_Name": [ - "unb2-sim" + "unb2-sim.service.consul" ], "OPC_Server_Port": [ "4841" diff --git a/README.md b/README.md index ce12889e171f63b3b63096c3ba64af7f248c80b5..c47030064f26c332cfd4e5ac19d1d174ed7b10db 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ You will also need: * make * bash * dig (dnsutils package on ubuntu/debian) +* jq * wget * hexdump (bsdextrautils package on ubuntu/debian) * gcc diff --git a/docker-compose/integration-test.yml b/docker-compose/integration-test.yml index d31670e157af42391c12f8e8b8393d608da18f75..fa50df0dd874759a02794ff29f4fcf1c6af30976 100644 --- a/docker-compose/integration-test.yml +++ b/docker-compose/integration-test.yml @@ -20,9 +20,8 @@ services: container_name: integration-test networks: - control - dns: ${DNS} - extra_hosts: - - "host.docker.internal:host-gateway" + dns: + - ${DNS} volumes: - ..:/opt/lofar/tango:rw environment: @@ -30,14 +29,12 @@ services: - TEST_MODULE=${TEST_MODULE} working_dir: /opt/lofar/tango/tangostationcontrol entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - tox -e integration -- + - tox command: # Allow for arguments to be passed that wil be put after the entrypoint # tox is configured to take these arguments as integration test directory # specifications. + - -e + - integration + - -- - "" diff --git a/docker-compose/object-storage.yml b/docker-compose/object-storage.yml deleted file mode 100644 index 66dd059e4cc0d2e2fc672c862d0ec796f29673d6..0000000000000000000000000000000000000000 --- a/docker-compose/object-storage.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 -# -# Docker compose file that launches Minio as a S3 compatible object storage. A UI is available via http -# -# Connect by surfing to http://localhost:9001/ -# View logs through 'docker logs -f -t object-storage' - -version: '2.1' - -services: - # the object storage is started by nomad/jumppad. This only populates the data for the integration tests - init-object-storage: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/mc:${MINIO_CLIENT_VERSION} - networks: - - control - dns: ${DNS} - volumes: - - ..:/opt/lofar/tango:rw - entrypoint: '' - command: > - sh -c "mc alias set object-storage http://s3.service.consul:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD - echo 'Initialising caltables' - mc mb --with-versioning object-storage/caltables - mc cp --recursive /opt/lofar/tango/docker-compose/object-storage/caltables/ object-storage/caltables/ - echo 'Initialising IERS tables' - mc mb --with-versioning object-storage/iers - mc cp --recursive /opt/lofar/tango/docker-compose/object-storage/iers/ object-storage/iers/ - date +'%F %T' - echo 'Initialisation completed'" - diff --git a/infra/dev/main.hcl b/infra/dev/main.hcl deleted file mode 100644 index 48a04f5e7892926069a4228938bec5149e942f99..0000000000000000000000000000000000000000 --- a/infra/dev/main.hcl +++ /dev/null @@ -1,32 +0,0 @@ -variable "host_volume" { - default = "dev_nomad_station" -} - -module "nomad" { - source = "./nomad" - variables = { - host_volume = "${variable.host_volume}" - } -} - -resource "nomad_job" "tango" { - cluster = module.nomad.output.nomad_cluster - - paths = ["./jobs/station/tango.nomad"] - - health_check { - timeout = "1000s" - jobs = ["tango"] - } -} - -resource "nomad_job" "object-storage" { - cluster = module.nomad.output.nomad_cluster - - paths = ["./jobs/station/object-storage.nomad"] - - health_check { - timeout = "1000s" - jobs = ["object-storage"] - } -} diff --git a/infra/dev/nomad/config/cni/station-control.conflist b/infra/dev/nomad/config/cni/station-control.conflist new file mode 100644 index 0000000000000000000000000000000000000000..376e6dea18c19ceffa4f47113f08b5a28c3be222 --- /dev/null +++ b/infra/dev/nomad/config/cni/station-control.conflist @@ -0,0 +1,27 @@ +{ + "cniVersion": "0.4.0", + "name": "station-control", + "plugins": [ + { + "type": "bridge", + "bridge": "br9000", + "isDefaultGateway": true, + "forceAddress": false, + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "172.31.0.0/16" + } + }, + { + "type": "firewall", + "backend": "iptables", + "iptablesAdminChainName": "CNI-BR9000" + }, + { + "type": "portmap", + "capabilities": { "portMappings": true }, + "snat": true + } + ] +} diff --git a/infra/dev/nomad/config/nomad/client.hcl b/infra/dev/nomad/config/nomad/client.hcl index 5312a79f7aef599628103a691df44ae26f606b17..5af057fc9ba610d39b189df15e2b0a37c2457193 100644 --- a/infra/dev/nomad/config/nomad/client.hcl +++ b/infra/dev/nomad/config/nomad/client.hcl @@ -25,14 +25,18 @@ client { path = "/localdata/volumes/tango-database" } - host_volume "jupyter-notebooks" { - path = "/localdata/volumes/jupyter-notebooks" - } - host_volume "object-storage-data" { path = "/localdata/volumes/object-storage-data" } + host_volume "IERS" { + path = "/localdata/volumes/IERS-data" + } + + host_volume "jupyter-notebooks" { + path = "/localdata/volumes/jupyter-notebooks" + } + options = { "driver.allowlist" = "docker,exec" } diff --git a/infra/dev/nomad/config/resolv.conf b/infra/dev/nomad/config/resolv.conf new file mode 100644 index 0000000000000000000000000000000000000000..470de50cb48599adad4afb79d81ce11fdf38c265 --- /dev/null +++ b/infra/dev/nomad/config/resolv.conf @@ -0,0 +1 @@ +nameserver 192.168.123.100 diff --git a/infra/dev/nomad/nomad.hcl b/infra/dev/nomad/nomad.hcl index 7cf12773d046c8ea159d66f9bbe54bde992746e0..9d8abe433314e8d0e5175c87313afc623352ed43 100644 --- a/infra/dev/nomad/nomad.hcl +++ b/infra/dev/nomad/nomad.hcl @@ -49,7 +49,7 @@ resource "container" "consul" { } image { - name = "git.astron.nl:5000/lofar2.0/tango/consul:latest" + name = "hashicorp/consul:latest" } command = [ @@ -94,16 +94,43 @@ resource "nomad_cluster" "station" { id = resource.network.station.id } environment = { - NO_PROXY = "git.astron.nl:5000" + NO_PROXY = "astron.nl,control.lofar,10.0.0.0/8" } - - image { - name = "git.astron.nl:5000/lofar2.0/tango/nomad:1.6.1" - } - volume { source = "${variable.host_volume}" destination = "/localdata" type = "volume" } + volume { + source = "./config/cni" + destination = "/opt/cni/config" + } + volume { + source = "./config/resolv.conf" + destination = "/etc/resolv.conf" + } + volume { + source = "/etc/docker/daemon.json" + destination = "/etc/docker/daemon.json" + } + copy_image { + name = "git.astron.nl:5000/lofar2.0/tango/ec-sim:${variable.image_tag}" + } + copy_image { + name = "git.astron.nl:5000/lofar2.0/tango/lofar-device-base:${variable.image_tag}" + } +} + +resource "exec" "enable_oversubscription" { + depends_on = ["resource.nomad_cluster.station"] + environment = { + NOMAD_ADDR="http://${resource.nomad_cluster.station.external_ip}:${resource.nomad_cluster.station.api_port}" + } + timeout = "3000s" + script = <<-EOF + #!/bin/bash + data=$(wget -qO- $NOMAD_ADDR/v1/operator/scheduler/configuration | \ + jq '.SchedulerConfig | .MemoryOversubscriptionEnabled=true') + wget --method=PUT --body-data="$data" -qO- $NOMAD_ADDR/v1/operator/scheduler/configuration + EOF } diff --git a/infra/dev/nomad/variables.hcl b/infra/dev/nomad/variables.hcl index 6deffdedc1a4c8782220efd5f4b60e1ae628619b..78e8930b4b538e991fd235b68d16e5fc88ce37e6 100644 --- a/infra/dev/nomad/variables.hcl +++ b/infra/dev/nomad/variables.hcl @@ -2,6 +2,17 @@ variable "host_volume" { default = "dev_nomad_station" } +variable "image_tag" { + default = "latest" +} + +variable "docker_host" { + default = "unix:///var/run/docker.sock" +} + output "nomad_cluster" { value = resource.nomad_cluster.station } +output "network_id" { + value = resource.network.station.id +} diff --git a/infra/dev/tango.hcl b/infra/dev/tango.hcl new file mode 100644 index 0000000000000000000000000000000000000000..a0f7ba36814b08a8f1a4455aef97c2073c3cd765 --- /dev/null +++ b/infra/dev/tango.hcl @@ -0,0 +1,154 @@ +variable "host_volume" { + default = "dev_nomad_station" +} +variable "lofar20_dir" { + default = "" +} +variable "image_tag" { + default = "latest" +} + +variable "docker_host" { + default = "unix:///var/run/docker.sock" +} + +module "nomad" { + source = "./nomad" + variables = { + host_volume = "${variable.host_volume}" + image_tag = "${variable.image_tag}" + docker_host = "${variable.docker_host}" + } +} + +resource "nomad_job" "tango" { + cluster = module.nomad.output.nomad_cluster + + paths = ["./jobs/station/tango.nomad"] + + health_check { + timeout = "1000s" + jobs = ["tango"] + } +} + +resource "nomad_job" "object-storage" { + cluster = module.nomad.output.nomad_cluster + + paths = ["./jobs/station/object-storage.nomad"] + + health_check { + timeout = "1000s" + jobs = ["object-storage"] + } +} + +resource "exec" "init-object-storage" { + depends_on = ["resource.nomad_job.object-storage"] + timeout = "1800s" + environment = { + DOCKER_HOST="${variable.docker_host}" + } + script = <<-EOF + #!/bin/bash + echo -n "Waiting for s3 service to become available .." + until [[ $(dig @127.0.0.1 -p 8600 s3.service.consul +short) ]]; do + sleep 2 + echo -n "." + done + echo ". [ok]" + + docker run --rm -i --network="station" --dns="192.168.123.100" busybox \ + sh -c "while true; do + wget -T 15 -c http://s3.service.consul:9000/minio/v2/metrics/cluster && break + sleep 2 + done" + + docker run --rm -i --network="station" --dns="192.168.123.100" --entrypoint bash \ + -v "${variable.lofar20_dir}":/opt/lofar/tango:rw \ + minio/mc:RELEASE.2023-10-14T01-57-03Z \ + -c "mc alias set object-storage http://s3.service.consul:9000 minioadmin minioadmin + echo 'Initialising caltables' + mc mb object-storage/caltables + mc cp --recursive /opt/lofar/tango/docker-compose/object-storage/caltables/ object-storage/caltables/ + echo 'Initialising IERS tables' + mc mb object-storage/iers + mc cp --recursive /opt/lofar/tango/docker-compose/object-storage/iers/ object-storage/iers/ + date +'%F %T' + echo 'Initialisation completed'" + EOF +} + +resource "nomad_job" "simulators" { + cluster = module.nomad.output.nomad_cluster + + paths = ["./jobs/station/simulators.nomad"] + + health_check { + timeout = "1000s" + jobs = ["simulators"] + } +} + +resource "nomad_job" "ec-sim" { + cluster = module.nomad.output.nomad_cluster + + paths = ["./jobs/station/ec-sim.nomad"] + + health_check { + timeout = "1000s" + jobs = ["ec-sim"] + } +} + +resource "exec" "dsconfig" { + depends_on = ["resource.nomad_job.tango"] + environment = { + DNS="192.168.123.100" + DOCKER_HOST="${variable.docker_host}" + } + working_directory = "${variable.lofar20_dir}" + timeout = "3000s" + script = <<-EOF + #!/bin/bash + echo "Docker host is $DOCKER_HOST" + echo -n "Waiting for tango service to become available .." + until [[ $(dig @127.0.0.1 -p 8600 tango.service.consul +short) ]]; do + sleep 2 + echo -n "." + done + echo ". [ok]" + + tango_port=$(dig @127.0.0.1 -p 8600 tango.service.consul SRV +short | awk '{printf "%s",$3}') + tango_host=$(dig @127.0.0.1 -p 8600 tango.service.consul +short) + + export TANGO_HOST="$tango_host:$tango_port" + + + echo "Using tango host $TANGO_HOST" + bash sbin/dsconfig.sh --load CDB/stations/common.json + bash sbin/dsconfig.sh --update CDB/stations/l0.json + bash sbin/dsconfig.sh --update CDB/stations/l1.json + bash sbin/dsconfig.sh --update CDB/stations/lba.json + bash sbin/dsconfig.sh --update CDB/stations/h0.json + bash sbin/dsconfig.sh --update CDB/stations/hba_core.json + bash sbin/dsconfig.sh --update CDB/stations/cs001.json + bash sbin/dsconfig.sh --update CDB/stations/testenv_cs001.json + EOF +} + +resource "nomad_job" "device-servers" { + depends_on = [ + "resource.exec.dsconfig", + "resource.exec.init-object-storage", + "resource.nomad_job.object-storage" + ] + cluster = module.nomad.output.nomad_cluster + + paths = ["./jobs/station/device-server.nomad"] + + health_check { + timeout = "3000s" + jobs = ["device-servers"] + } +} diff --git a/infra/env.yaml b/infra/env.yaml index a3b3202358c3da9b5d7dadecb24d86e01729adae..01ab05cb1601be2b3c4feacb7747d0079cc6f197 100644 --- a/infra/env.yaml +++ b/infra/env.yaml @@ -21,19 +21,45 @@ object_storage: name: minioadmin pass: minioadmin +pypcc: + version: latest + +simulators: + pypcc: + unb2: + port: 4841 + config: UNB2TR + apspu: + port: 4842 + config: APSPUTR + ccd: + port: 4843 + config: CCDTR + recvh: + port: 4844 + config: RECVTR_HB,PPS + recvl: + port: 4845 + config: RECVTR_LB,PPS + apsct: + port: 4846 + config: APSCTTR + sdptr: - lba: - port: 4840 - first_gn: 0 - fpgas: 16 - hba0: - port: 4842 - first_gn: 16 - fpgas: 4 - hba1: - port: 4844 - first_gn: 20 - fpgas: 4 + version: latest + instances: + lba: + port: 4840 + first_gn: 0 + fpgas: 16 + hba0: + port: 4842 + first_gn: 16 + fpgas: 4 + hba1: + port: 4844 + first_gn: 20 + fpgas: 4 devices: - class: AFH @@ -54,7 +80,6 @@ devices: - class: CCD - class: Configuration - class: DigitalBeam - - class: Docker - class: EC - class: ObservationControl - class: PCON diff --git a/infra/jobs/station/Makefile b/infra/jobs/station/Makefile index e145e6a681aa387879d908d0646d776f4a764162..15bcff97bce249bc9ef432c2043b42d3e3bef57f 100644 --- a/infra/jobs/station/Makefile +++ b/infra/jobs/station/Makefile @@ -12,7 +12,7 @@ ENV ?= ../../env.yaml render: pull $(JOBS) $(DEVICES) pull: - docker pull -q git.astron.nl:5000/lofar2.0/tango/levant + docker pull -q hashicorp/levant %.nomad: %.levant.nomad - docker run --rm -v $(realpath $(ENV)):/env.yaml -v $(realpath $(DIR_SRC)):/in -v $(realpath $(DIR_OUT)):/out git.astron.nl:5000/lofar2.0/tango/levant render -var-file=/env.yaml -var image_tag="$(TAG)" -var station="$(STATION)" -out=/out/$@ /in/$< + docker run --rm -v $(realpath $(ENV)):/env.yaml -v $(realpath $(DIR_SRC)):/in -v $(realpath $(DIR_OUT)):/out hashicorp/levant render -var-file=/env.yaml -var image_tag="$(TAG)" -var station="$(STATION)" -out=/out/$@ /in/$< diff --git a/infra/jobs/station/device-server.levant.nomad b/infra/jobs/station/device-server.levant.nomad index ed0074d107338b3614fdc1658cabdec20db4261b..fae14480bc587d2740271d3e4dd84a35bcd90983 100644 --- a/infra/jobs/station/device-server.levant.nomad +++ b/infra/jobs/station/device-server.levant.nomad @@ -21,8 +21,7 @@ job "device-servers" { service { tags = ["scrape"] - name = "sync-IERS" - port = "sync-IERS" + name = "sync-iers" meta { metrics_address = "${NOMAD_ADDR_metrics}" metrics_path = "/" @@ -46,7 +45,7 @@ job "device-servers" { config { image = "minio/mc:latest" - entrypoint = "" + entrypoint = [""] command = "/bin/bash" args = ["-c", "mc alias set object-storage http://s3.service.consul:9000 [[.object_storage.user.name]] [[.object_storage.user.pass]] && mc mirror --preserve --watch object-storage/iers/ /opt/IERS/" ] } diff --git a/infra/jobs/station/ec-sim.levant.nomad b/infra/jobs/station/ec-sim.levant.nomad index ba2fa2e4c2b3526e00e0800682a397f621ac1b1c..5d07e9331b654012aa5913485880c1c2372062fb 100644 --- a/infra/jobs/station/ec-sim.levant.nomad +++ b/infra/jobs/station/ec-sim.levant.nomad @@ -1,4 +1,4 @@ -job "simulators" { +job "ec-sim" { datacenters = ["stat"] type = "service" diff --git a/infra/jobs/station/logging.levant.nomad b/infra/jobs/station/logging.levant.nomad index 8046f4f61be26d5d5f6d27f4fbccdb938e8a0b5c..33e3fc10e183c9df92aa53c2ce0c02fe2399b43f 100644 --- a/infra/jobs/station/logging.levant.nomad +++ b/infra/jobs/station/logging.levant.nomad @@ -55,7 +55,7 @@ job "log-scraping" { task "vector" { driver = "docker" config { - image = "[[.registry.astron.url]]/vector:0.32.1.custom.989ad14-distroless-static" + image = "timberio/vector:0.32.1.custom.989ad14-distroless-static" ports = ["api"] } # docker socket volume mount diff --git a/infra/jobs/station/nomad-client.nomad b/infra/jobs/station/nomad-client.nomad index 1d82d38c66545846392a8122ea471317ba77888c..9a0f8c495ecd25a371a2fc21d75252a663d56d51 100644 --- a/infra/jobs/station/nomad-client.nomad +++ b/infra/jobs/station/nomad-client.nomad @@ -78,6 +78,7 @@ job "nomad-client" { - [systemctl, enable, docker.service] - [systemctl, start, docker.service] - iptables -A CNI-BR9000 -d 172.31.0.0/16 -j ACCEPT + - sysctl -w net.core.rmem_max=16777216 package_update: true package_upgrade: true diff --git a/infra/jobs/station/object-storage.levant.nomad b/infra/jobs/station/object-storage.levant.nomad index 1852e26cc8635e3c0e730aa622258c94a7969aa0..8059772e43383efe1e2a420208822b7f62ea2aee 100644 --- a/infra/jobs/station/object-storage.levant.nomad +++ b/infra/jobs/station/object-storage.levant.nomad @@ -52,7 +52,7 @@ job "object-storage" { } config { - image = "[[.registry.astron.url]]/minio:[[.object_storage.minio.version]]" + image = "minio/minio:[[.object_storage.minio.version]]" ports = ["s3", "console"] command = "server" args = ["--console-address", ":9001", "/data"] @@ -70,16 +70,20 @@ job "object-storage" { resources { cpu = 250 - memory = 512 + memory = 2048 + memory_max = 8192 } } task "vector" { driver = "docker" config { - image = "[[.registry.astron.url]]/vector:0.32.1.custom.989ad14-distroless-static" + image = "timberio/vector:0.32.1.custom.989ad14-distroless-static" ports = ["metrics"] } + lifecycle { + sidecar = true + } # Vector won't start unless the sinks(backends) configured are healthy env { VECTOR_CONFIG = "local/vector.toml" @@ -87,8 +91,8 @@ job "object-storage" { } # resource limits are a good idea because you don't want your log collection to consume all resources available resources { - cpu = 10 # 500 MHz - memory = 50 # 256MB + cpu = 10 + memory = 256 # 256MB } # template with Vector's configuration template { diff --git a/infra/jobs/station/sdptr.levant.nomad b/infra/jobs/station/sdptr.levant.nomad index 127d390d44d448eb679c05ed49400d55a681e858..4d09f69b31503b8f2069493f90bd86a6fbe185c0 100644 --- a/infra/jobs/station/sdptr.levant.nomad +++ b/infra/jobs/station/sdptr.levant.nomad @@ -2,7 +2,7 @@ job "sdptr" { datacenters = ["stat"] type = "service" - [[ range $name, $tr := $.sdptr ]] + [[ range $name, $tr := $.sdptr.instances ]] group "[[ $name ]]" { count = 1 network { @@ -23,7 +23,7 @@ job "sdptr" { config { - image = "git.astron.nl:5000/lofar2.0/sdptr:latest" + image = "git.astron.nl:5000/lofar2.0/sdptr:[[ $.sdptr.version ]]" ports = ["sdptr"] command = "/usr/local/bin/sdptr-[[ $name ]]" args = [ diff --git a/infra/jobs/station/simulators.levant.nomad b/infra/jobs/station/simulators.levant.nomad new file mode 100644 index 0000000000000000000000000000000000000000..5618900b51bd60735fae51a61ea8a93ab5b85f1d --- /dev/null +++ b/infra/jobs/station/simulators.levant.nomad @@ -0,0 +1,70 @@ +job "simulators" { + datacenters = ["stat"] + type = "service" + + [[ range $name, $tr := $.simulators.pypcc ]] + group "[[ $name ]]-sim" { + count = 1 + + network { + mode = "bridge" + port "opcua" { + static = [[ $tr.port ]] + to = [[ $tr.port ]] + } + } + + service { + name = "[[ $name ]]-sim" + port = "opcua" + } + + task "sim" { + driver = "docker" + + config { + image = "git.astron.nl:5000/lofar2.0/pypcc:[[ $.pypcc.version ]]" + ports = ["opcua"] + entrypoint = ["hwtr", "--simulator", "--port", "[[ $tr.port ]]", "--config", "[[ $tr.config ]]"] + } + resources { + cpu = 100 + memory = 256 + } + } + } + [[ end ]] + + + group "sdptr-sim" { + count = 1 + + network { + mode = "bridge" + port "opcua" { + static = 4840 + to = 4840 + } + } + + service { + name = "sdptr-sim" + port = "opcua" + } + + task "sim" { + driver = "docker" + + config { + image = "git.astron.nl:5000/lofar2.0/sdptr:[[ $.sdptr.version ]]" + ports = ["opcua"] + entrypoint = ["/usr/local/bin/sdptr", "--ip_prefix=127.0.", "--nodaemon"] + } + resources { + cpu = 100 + memory = 100 + } + } + + } +} diff --git a/infra/main.hcl b/infra/main.hcl new file mode 100644 index 0000000000000000000000000000000000000000..6b5f8e48cb03c9002dfbcecce8012f9f18b3df83 --- /dev/null +++ b/infra/main.hcl @@ -0,0 +1,64 @@ +resource "network" "station" { + subnet = "192.168.123.0/16" +} + +resource "container" "consul" { + network { + id = resource.network.station.id + ip_address = "192.168.123.200" + aliases = ["consul"] + } + + image { + name = "consul:1.6.1" + } + + command = [ + "consul", + "agent" + ] + + environment = { + CONSUL_HTTP_ADDR = "http://localhost:8500" + } + + port { + local = 8500 + remote = 8500 + host = 18500 + } + + port_range { + range = "9000-9002" + enable_host = true + } + + privileged = false +} + +resource "nomad_cluster" "station" { + depends_on = ["resource.container.consul"] + client_nodes = 1 + client_config = "./config/client.hcl" + + network { + id = resource.network.station.id + } + + volume { + source = "./volumes" + destination = "/localdata/volumes" + type = "bind" + } +} + +resource "nomad_job" "tango" { + cluster = resource.nomad_cluster.station + + paths = ["./jobs/tango.nomad"] + + health_check { + timeout = "30s" + jobs = ["tango"] + } +} diff --git a/sbin/prepare_dev_env.sh b/sbin/prepare_dev_env.sh index 0d20b2ecfa3735b9d845f8ac3656e128fc145488..a997a395958d7cd44f93161322a963234e537641 100755 --- a/sbin/prepare_dev_env.sh +++ b/sbin/prepare_dev_env.sh @@ -5,7 +5,7 @@ # # Url to the jumppad download location -jumppad_download="https://git.astron.nl/lofar2.0/tango/-/package_files/40604/download" +jumppad_download="https://git.astron.nl/lofar2.0/tango/-/package_files/41059/download" if [ -z "$LOFAR20_DIR" ]; then # We assume we aren't in the PATH, so we can derive our path. @@ -62,13 +62,14 @@ if [ "$(docker volume list | grep -c "$docker_volume")" = "0" ]; then docker volume create "$docker_volume" fi -docker pull -q git.astron.nl:5000/lofar2.0/tango/bash -docker run --rm -i -v "$docker_volume":/mnt git.astron.nl:5000/lofar2.0/tango/bash bash <<- EOM +docker pull -q bash +docker run --rm -i -v "$docker_volume":/mnt bash bash <<- EOM mkdir -p /mnt/volumes/tango-database mkdir -p /mnt/volumes/monitoring-postgresql-data mkdir -p /mnt/volumes/monitoring-loki-data mkdir -p /mnt/volumes/monitoring-prometheus-data mkdir -p /mnt/volumes/object-storage-data mkdir -p /mnt/volumes/jupyter-notebooks + mkdir -p /mnt/volumes/IERS-data chmod 0777 -R /mnt/volumes EOM diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index b326f47784f8dedbfcffe2febb462229d383e20e..1afd339d7be804b5763d9a96cffb6fb8245c827d 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -5,6 +5,7 @@ # export HOSTNAME=192.168.123.1 +export DNS=192.168.123.100 # Usage function explains how parameters are parsed function usage { @@ -27,33 +28,15 @@ function usage { echo "" echo "./$(basename "$0") --save-logs Export logs for each container into the /log directory" + echo "" + echo "./$(basename "$0") --module=<tango|services> + Only start a subset of the infrastructure, if left out everything is started" } -# Configure the config database, restart containers and run a specific -# integration module or even specific tests -# integration_test module restarted_containers config_files specific_test -function integration_test { - IFS=" " read -r -a restarts <<< "${2}" - IFS=" " read -r -a configs <<< "${3}" - for config in "${configs[@]}"; do - echo "Updating config ${config} ..." - bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${config}" - done - if [ -n "${2+x}" ]; then - # shellcheck disable=SC2145 - echo "make restart ${restarts[@]} ..." - make restart "${restarts[@]}" - # shellcheck disable=SC2145 - echo "make await ${restarts[@]} ..." - make await "${restarts[@]}" - fi - echo "make integration ${1} ..." - make integration "${1}" -} # list of arguments expected in the input -optstring_long="help,no-build,skip-tests,preserve,save-logs" +optstring_long="help,no-build,skip-tests,preserve,save-logs,module::" optstring="h" options=$(getopt -l ${optstring_long} -o ${optstring} -- "$@") @@ -85,6 +68,11 @@ while true; do echo "Save logs after execution" export save_logs=1 ;; + --module) + shift + module="$1" + ;; + --) shift break;; @@ -108,7 +96,7 @@ fi echo "Using TAG: ${TAG}" echo "Using DNS: ${DNS}" -# Build dsconfig and tango device image first, `-z ${y+x}` is the inverse of `-n ${y}` +# Build dsconfig first, `-z ${y+x}` is the inverse of `-n ${y}` if [ -z "${no_build+x}" ]; then rm -rf "${LOFAR20_DIR}/tangostationcontrol/dist" cd "${LOFAR20_DIR}/tangostationcontrol" || exit 1 @@ -143,6 +131,54 @@ function cleanup { trap cleanup EXIT +# Configure the config database, restart containers and run a specific +# integration module or even specific tests +# integration_test module restarted_containers config_files specific_test +function integration_test { + IFS=" " read -r -a restarts <<< "${2}" + IFS=" " read -r -a configs <<< "${3}" + for config in "${configs[@]}"; do + echo "Updating config ${config} ..." + bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${config}" + done + if [ -n "${2+x}" ]; then + # shellcheck disable=SC2145 + echo "restart device-servers restart ..." + docker exec -i server.station.nomad.nomad-cluster.jumppad.dev nomad job restart -on-error=fail device-servers + # shellcheck disable=SC2145 + echo "await ${restarts[@]} ..." + await "${restarts[@]}" + fi + + docker_args=( + run --rm -e "TANGO_HOST=$TANGO_HOST" --network="station" --dns="$DNS" -i + -v "$LOFAR20_DIR":/opt/lofar/tango:rw + -w="/opt/lofar/tango/tangostationcontrol" + ) + echo "run integration ${1} ..." + docker "${docker_args[@]}" -e "TEST_MODULE=${1}" "git.astron.nl:5000/lofar2.0/tango/ci-build-runner:$TAG" \ + tox -e integration +} + +function await { + timeout_sec=30 + start_time="$(date -u +%s)" + for i in "$@"; do + echo -n "Wait for service ${i} to become healthy .."; \ + while [ "$(docker exec -i server.station.nomad.nomad-cluster.jumppad.dev nomad job allocs -json device-servers | jq -r ".[] | select(.TaskGroup == \"${1}\") | .TaskStates[].State")" != "running" ] ; do + echo -n '.'; + sleep 2; + current_time="$(date -u +%s)" + elapsed_seconds=$("$current_time"-"$start_time") + if [ "${elapsed_seconds}" -gt "${timeout_sec}" ]; then + echo ". [timeout]"; + exit 1; + fi; + done; + echo ". [ok]"; + done +} + cd "$LOFAR20_DIR" || exit 1 source "${LOFAR20_DIR}"/sbin/prepare_dev_env.sh --volume="$tmp_volume" @@ -153,7 +189,31 @@ fi rm -rf "$JUMPPAD_HOME/.jumppad/" -HOME="$JUMPPAD_HOME" jumppad up --var="host_volume=$tmp_volume" infra/dev/main.hcl +# Update the dsconfig +docker pull -q "git.astron.nl:5000/lofar2.0/tango/dsconfig:$TAG" || docker pull -q "git.astron.nl:5000/lofar2.0/tango/dsconfig:latest" || true +if [ -n "$(docker image inspect \""git.astron.nl:5000/lofar2.0/tango/dsconfig":"${TAG}"\")" ]; then + docker tag "git.astron.nl:5000/lofar2.0/tango/dsconfig:latest" "git.astron.nl:5000/lofar2.0/tango/dsconfig:$TAG" +fi + +jumppad_options=( + --var="host_volume=$tmp_volume" + --var="lofar20_dir=$LOFAR20_DIR" + --var="image_tag=$TAG" +) + +if [ -n "$DOCKER_HOST" ]; then + echo "Set docker host to: $DOCKER_HOST" + jumppad_options+=(--var="docker_host=$DOCKER_HOST") +fi + +if [ -z ${module+x} ]; then + jumppad_options+=("infra/dev/") +else + echo "Only start module: $module" + jumppad_options+=("infra/dev/$module.hcl") +fi + +HOME="$JUMPPAD_HOME" jumppad up "${jumppad_options[@]}" echo -n "Waiting for tango service to become available .." until [[ $(dig @127.0.0.1 -p 8600 tango.service.consul +short) ]]; do @@ -174,60 +234,25 @@ cd "$LOFAR20_DIR/docker-compose" || exit 1 # Devices list is used to explitly word split when supplied to commands, must # disable shellcheck SC2086 for each case. -DEVICES=(device-station-manager device-aps device-apsct device-ccd device-ec device-apspu device-sdpfirmware device-sdp device-recvh device-recvl device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-afh device-afl device-temperature-manager device-observation-control device-configuration device-calibration) - -SIMULATORS=(sdptr-sim recvh-sim recvl-sim unb2-sim apsct-sim apspu-sim ccd-sim ec-sim) +DEVICES=(device-stationmanager device-aps device-apsct device-ccd device-ec device-apspu device-sdpfirmware device-sdp device-recvh device-recvl device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-afh device-afl device-temperaturemanager device-observationcontrol device-configuration device-calibration) # Build only the required images, please do not build everything that makes CI # take really long to finish, especially grafana / jupyter / prometheus. # jupyter is physically large > 2.5gb and overlayfs is really slow. -[ -n "${no_build}" ] || make build "${SIMULATORS[@]}" [ -n "${no_build}" ] || make build integration-test -# Start and stop sequence -make stop init-object-storage -make stop "${DEVICES[@]}" "${SIMULATORS[@]}" -make stop device-docker # this one does not test well in docker-in-docker - -make start init-object-storage - -# Update the dsconfig -docker pull -q "git.astron.nl:5000/lofar2.0/tango/dsconfig:$TAG" || docker pull -q "git.astron.nl:5000/lofar2.0/tango/dsconfig:latest" || true -if [ -n "$(docker image inspect \""git.astron.nl:5000/lofar2.0/tango/dsconfig":"${TAG}"\")" ]; then - docker tag "git.astron.nl:5000/lofar2.0/tango/dsconfig:latest" "git.astron.nl:5000/lofar2.0/tango/dsconfig:$TAG" -fi - -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --load "${LOFAR20_DIR}"/CDB/stations/common.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/l0.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/l1.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/lba.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/h0.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/hba_core.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/cs001.json -bash "${LOFAR20_DIR}"/sbin/dsconfig.sh --update "${LOFAR20_DIR}"/CDB/stations/testenv_cs001.json - cd "$LOFAR20_DIR/docker-compose" || exit 1 -make start "${SIMULATORS[@]}" - -make start grafana prometheus prometheus-node-exporter tango-prometheus-fast-exporter tango-prometheus-slow-exporter tango-prometheus-exporter - -# Give the simulators time to start -sleep 5 - -# shellcheck disable=SC2086 -make start "${DEVICES[@]}" # Wait for devices to restart -make await "${DEVICES[@]}" + +await "${DEVICES[@]}" if [ -n "${no_tests}" ]; then exit 0 fi # Start the integration test -cd "$LOFAR20_DIR/docker-compose" || exit 1 -make up integration-test integration_test default @@ -237,4 +262,3 @@ integration_test digitalbeam_performance "device-sdpfirmware device-sdp device-r integration_test configuration "device-configuration" -make restart "${DEVICES[@]}" diff --git a/sbin/run_service_test.sh b/sbin/run_service_test.sh index d0718a84bf79a935947b8670ddee965b5389d362..806f4774e620416891f9414134d7e8e9bd776404 100755 --- a/sbin/run_service_test.sh +++ b/sbin/run_service_test.sh @@ -48,4 +48,15 @@ fi rm -rf "$JUMPPAD_HOME/.jumppad/" -HOME="$JUMPPAD_HOME" jumppad up --var="host_volume=$tmp_volume" infra/dev/services.hcl || true +jumppad_options=( + --var="host_volume=$tmp_volume" + --var="lofar20_dir=$LOFAR20_DIR" + --var="image_tag=$TAG" +) + +if [ -n "$DOCKER_HOST" ]; then + echo "Set docker host to: $DOCKER_HOST" + jumppad_options+=(--var="docker_host=$DOCKER_HOST") +fi + +HOME="$JUMPPAD_HOME" jumppad up "${jumppad_options[@]}" infra/dev/services.hcl diff --git a/sbin/tag_and_push_docker_image.sh b/sbin/tag_and_push_docker_image.sh index 863d201b07d19ef96c8a12d5b17438c762b9d720..f39c8315cad662c6d47ad48480151dd50523102a 100755 --- a/sbin/tag_and_push_docker_image.sh +++ b/sbin/tag_and_push_docker_image.sh @@ -103,8 +103,6 @@ LOCAL_IMAGES=( "jupyter-lab jupyter-lab n" "integration-test docker-compose_integration-test n" "tango-prometheus-exporter tango-prometheus-exporter n" - - "alpine alpine y" ) # LOCAL_IMAGES verifier, this has been going wrong a couple of times diff --git a/tangostationcontrol/integration_test/default/client/test_sdptr_sim.py b/tangostationcontrol/integration_test/default/client/test_sdptr_sim.py index d6a85e9eddcdbd9c655c75ed8d1d04d19f5b6b62..711d27556384892a6d5971aeda1196e74df0aaec 100644 --- a/tangostationcontrol/integration_test/default/client/test_sdptr_sim.py +++ b/tangostationcontrol/integration_test/default/client/test_sdptr_sim.py @@ -13,7 +13,7 @@ class TestSDPTRSim(base.IntegrationAsyncTestCase): async def test_opcua_connection(self): """Check if we can connect to sdptr-sim""" - client = Client("opc.tcp://sdptr-sim:4840") + client = Client("opc.tcp://sdptr-sim.service.consul:4840") root_node = None try: diff --git a/tangostationcontrol/integration_test/default/client/test_unb2_sim.py b/tangostationcontrol/integration_test/default/client/test_unb2_sim.py index e323cd31e579fa4877f54fbc0ad6ead727ea14a7..d2aee824ba41015b346f6ab63ffe4fab2b20dbf3 100644 --- a/tangostationcontrol/integration_test/default/client/test_unb2_sim.py +++ b/tangostationcontrol/integration_test/default/client/test_unb2_sim.py @@ -13,7 +13,7 @@ class TestUNB2Sim(base.IntegrationAsyncTestCase): async def test_opcua_connection(self): """Check if we can connect to unb2-sim""" - client = Client("opc.tcp://unb2-sim:4841") + client = Client("opc.tcp://unb2-sim.service.consul:4841") root_node = None await client.connect() diff --git a/tangostationcontrol/integration_test/default/devices/test_device_sst.py b/tangostationcontrol/integration_test/default/devices/test_device_sst.py index 4975fd253f4a1ca4bbdbb4662e18418860c9afcf..990de4abeb087b4c346651a7f51ae02a3be043bf 100644 --- a/tangostationcontrol/integration_test/default/devices/test_device_sst.py +++ b/tangostationcontrol/integration_test/default/devices/test_device_sst.py @@ -27,7 +27,7 @@ class TestDeviceSST(AbstractTestBases.TestDeviceBase): self.assertEqual(DevState.ON, self.proxy.state()) s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s1.connect(("device-sst", 5001)) + s1.connect(("device-sst.service.consul", 5001)) # TODO(Corne): Change me into an actual SST packet s1.send("Hello World!".encode("UTF-8")) @@ -42,10 +42,10 @@ class TestDeviceSST(AbstractTestBases.TestDeviceBase): time.sleep(2) s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s1.connect(("device-sst", 5011)) + s1.connect(("device-sst.service.consul", 5011)) s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s2.connect(("device-sst", 5111)) + s2.connect(("device-sst.service.consul", 5111)) time.sleep(2) diff --git a/tangostationcontrol/tangostationcontrol/clients/docker_client.py b/tangostationcontrol/tangostationcontrol/clients/docker_client.py deleted file mode 100644 index 630d4c9c1bd4080648d2574b1bf073a513d11f0c..0000000000000000000000000000000000000000 --- a/tangostationcontrol/tangostationcontrol/clients/docker_client.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -import logging - -import docker - -from .comms_client import AsyncCommClient - -logger = logging.getLogger() - - -class DockerClient(AsyncCommClient): - """ - Controls & queries running docker containers. - """ - - def __init__(self, base_url, fault_func, event_loop=None): - super().__init__(fault_func, event_loop) - - self.base_url = base_url - - async def connect(self): - self.client = docker.DockerClient(self.base_url) - - async def ping(self): - # Raises if the server is unresponsive - self.client.ping() - - async def disconnect(self): - self.client = None - - async def setup_attribute(self, annotation, attribute): - """ - MANDATORY function: is used by the attribute wrapper to get read/write functions. must return the read and write functions - """ - - container_name = annotation["container"] - - def read_function(): - try: - container = self.client.containers.get(container_name) - except docker.errors.NotFound: - return False - - # expected values: running, restarting, paused, exited, created - return container.status == "running" - - def write_function(value): - container = self.client.containers.get(container_name) - - if value: - container.start() - else: - container.stop() - - return read_function, write_function diff --git a/tangostationcontrol/tangostationcontrol/devices/README.md b/tangostationcontrol/tangostationcontrol/devices/README.md index b60272af1274de2827fd22a689611afcb37db560..924faf2ff98bd3ca9c7cbe999d18a41dd21d917c 100644 --- a/tangostationcontrol/tangostationcontrol/devices/README.md +++ b/tangostationcontrol/tangostationcontrol/devices/README.md @@ -10,7 +10,6 @@ If a new device is added, it will (likely) need to be referenced in several plac - Add the device hierarchies in `CDB/hierarchies` to define the power, control and clock configuration, - Adjust `docker-compose/jupyter-lab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py` to make an alias for it available in Jupyter-Lab, - Adjust `tangostationcontrol/tangostationcontrol/devices/boot.py` to add the device to the station initialisation sequence, -- Adjust `tangostationcontrol/tangostationcontrol/devices/docker.py` to have the device container available as R and RW attributes, - Add to `docker-compose/` to create a YaML file to start the device in a docker container. NOTE: it needs a unique 57xx port assigned (current _unused_ port value: 5731), a unique 58xx port for ZMQ events, and a unique 59xx port for ZMQ heartbeat - Adjust `tangostationcontrol/setup.cfg` to add an entry point for the device in the package installation, - Add to `tangostationcontrol/tangostationcontrol/integration_test/default/devices/` to add an integration test, diff --git a/tangostationcontrol/tangostationcontrol/devices/__init__.py b/tangostationcontrol/tangostationcontrol/devices/__init__.py index acbde7b69d7a2d2bdbb00b6fc504b69dfa749d59..72b5e95a66c7a1dbee1e3b1bc86556638d8750f6 100644 --- a/tangostationcontrol/tangostationcontrol/devices/__init__.py +++ b/tangostationcontrol/tangostationcontrol/devices/__init__.py @@ -9,7 +9,6 @@ from .apspu import APSPU from .calibration import Calibration from .ccd import CCD from .configuration import Configuration -from .docker import Docker from .ec import EC from .observation_field import ObservationField from .observation_control import ObservationControl @@ -39,7 +38,6 @@ __all__ = [ "Calibration", "CCD", "Configuration", - "Docker", "EC", "ObservationField", "ObservationControl", diff --git a/tangostationcontrol/tangostationcontrol/devices/docker.py b/tangostationcontrol/tangostationcontrol/devices/docker.py deleted file mode 100644 index 506397d072a77da676d04fd2ebad82ccbae7103e..0000000000000000000000000000000000000000 --- a/tangostationcontrol/tangostationcontrol/devices/docker.py +++ /dev/null @@ -1,396 +0,0 @@ -# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -""" Docker Device Server for LOFAR2.0 - -""" - -import asyncio -import logging - -from attribute_wrapper.attribute_wrapper import AttributeWrapper -from tango import AttrWriteType - -# PyTango imports -from tango.server import device_property -from tangostationcontrol.clients.docker_client import DockerClient - -# Additional import -from tangostationcontrol.common.lofar_logging import ( - device_logging_to_python, - log_exceptions, -) -from tangostationcontrol.devices.base_device_classes.lofar_device import LOFARDevice - -logger = logging.getLogger() - -__all__ = ["Docker"] - - -@device_logging_to_python() -class Docker(LOFARDevice): - # ----------------- - # Device Properties - # ----------------- - - Docker_Base_URL = device_property( - dtype="DevString", mandatory=False, default_value="unix:///var/run/docker.sock" - ) - - # ---------- - # Attributes - # ---------- - - # Software devices - device_stationManager_R = AttributeWrapper( - comms_annotation={"container": "device-station-manager"}, datatype=bool - ) - device_stationManager_RW = AttributeWrapper( - comms_annotation={"container": "device-station-manager"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_boot_R = AttributeWrapper( - comms_annotation={"container": "device-boot"}, datatype=bool - ) - device_boot_RW = AttributeWrapper( - comms_annotation={"container": "device-boot"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_docker_R = AttributeWrapper( - comms_annotation={"container": "device-docker"}, datatype=bool - ) - device_configuration_R = AttributeWrapper( - comms_annotation={"container": "device-configuration"}, datatype=bool - ) - device_configuration_RW = AttributeWrapper( - comms_annotation={"container": "device-configuration"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_ec_R = AttributeWrapper( - comms_annotation={"container": "device-ec"}, datatype=bool - ) - device_ec_RW = AttributeWrapper( - comms_annotation={"container": "device-ec"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - # device_docker_RW is not available, as we cannot start our own container` - device_temperature_manager_R = AttributeWrapper( - comms_annotation={"container": "device-temperature-manager"}, datatype=bool - ) - device_temperature_manager_RW = AttributeWrapper( - comms_annotation={"container": "device-temperature-manager"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_observation_R = AttributeWrapper( - comms_annotation={"container": "device-observation"}, datatype=bool - ) - device_observation_RW = AttributeWrapper( - comms_annotation={"container": "device-observation"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_observation_control_R = AttributeWrapper( - comms_annotation={"container": "device-observation-control"}, datatype=bool - ) - device_observation_control_RW = AttributeWrapper( - comms_annotation={"container": "device-observation-control"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - - # Hardware devices - device_apsct_R = AttributeWrapper( - comms_annotation={"container": "device-apsct"}, datatype=bool - ) - device_apsct_RW = AttributeWrapper( - comms_annotation={"container": "device-apsct"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_apspu_R = AttributeWrapper( - comms_annotation={"container": "device-apspu"}, datatype=bool - ) - device_apspu_RW = AttributeWrapper( - comms_annotation={"container": "device-apspu"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_recvh_R = AttributeWrapper( - comms_annotation={"container": "device-recvh"}, datatype=bool - ) - device_recvh_RW = AttributeWrapper( - comms_annotation={"container": "device-recvh"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_recvl_R = AttributeWrapper( - comms_annotation={"container": "device-recvl"}, datatype=bool - ) - device_recvl_RW = AttributeWrapper( - comms_annotation={"container": "device-recvl"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_sdpfirmware_R = AttributeWrapper( - comms_annotation={"container": "device-sdpfirmware"}, datatype=bool - ) - device_sdpfirmware_RW = AttributeWrapper( - comms_annotation={"container": "device-sdpfirmware"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_sdp_R = AttributeWrapper( - comms_annotation={"container": "device-sdp"}, datatype=bool - ) - device_sdp_RW = AttributeWrapper( - comms_annotation={"container": "device-sdp"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_unb2_R = AttributeWrapper( - comms_annotation={"container": "device-unb2"}, datatype=bool - ) - device_unb2_RW = AttributeWrapper( - comms_annotation={"container": "device-unb2"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_pcon_R = AttributeWrapper( - comms_annotation={"container": "device-pcon"}, datatype=bool - ) - device_pcon_RW = AttributeWrapper( - comms_annotation={"container": "device-pcon"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_psoc_R = AttributeWrapper( - comms_annotation={"container": "device-psoc"}, datatype=bool - ) - device_psoc_RW = AttributeWrapper( - comms_annotation={"container": "device-psoc"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_ccd_R = AttributeWrapper( - comms_annotation={"container": "device-ccd"}, datatype=bool - ) - device_ccd_RW = AttributeWrapper( - comms_annotation={"container": "device-ccd"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - - # Statistics devices - device_sst_R = AttributeWrapper( - comms_annotation={"container": "device-sst"}, datatype=bool - ) - device_sst_RW = AttributeWrapper( - comms_annotation={"container": "device-sst"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_xst_R = AttributeWrapper( - comms_annotation={"container": "device-xst"}, datatype=bool - ) - device_xst_RW = AttributeWrapper( - comms_annotation={"container": "device-xst"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_bst_R = AttributeWrapper( - comms_annotation={"container": "device-bst"}, datatype=bool - ) - device_bst_RW = AttributeWrapper( - comms_annotation={"container": "device-bst"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - - # Beam devices - device_hba_R = AttributeWrapper( - comms_annotation={"container": "device-afh"}, datatype=bool - ) - device_hba_RW = AttributeWrapper( - comms_annotation={"container": "device-afh"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_lba_R = AttributeWrapper( - comms_annotation={"container": "device-afl"}, datatype=bool - ) - device_lba_RW = AttributeWrapper( - comms_annotation={"container": "device-afl"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_beamlet_R = AttributeWrapper( - comms_annotation={"container": "device-beamlet"}, datatype=bool - ) - device_beamlet_RW = AttributeWrapper( - comms_annotation={"container": "device-beamlet"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_digitalbeam_R = AttributeWrapper( - comms_annotation={"container": "device-digitalbeam"}, datatype=bool - ) - device_digitalbeam_RW = AttributeWrapper( - comms_annotation={"container": "device-digitalbeam"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - device_tilebeam_R = AttributeWrapper( - comms_annotation={"container": "device-tilebeam"}, datatype=bool - ) - device_tilebeam_RW = AttributeWrapper( - comms_annotation={"container": "device-tilebeam"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - - # Other containers - databaseds_R = AttributeWrapper( - comms_annotation={"container": "databaseds"}, datatype=bool - ) - databaseds_RW = AttributeWrapper( - comms_annotation={"container": "databaseds"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - dsconfig_R = AttributeWrapper( - comms_annotation={"container": "dsconfig"}, datatype=bool - ) - dsconfig_RW = AttributeWrapper( - comms_annotation={"container": "dsconfig"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - grafana_R = AttributeWrapper( - comms_annotation={"container": "grafana"}, datatype=bool - ) - grafana_RW = AttributeWrapper( - comms_annotation={"container": "grafana"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - logstash_R = AttributeWrapper( - comms_annotation={"container": "logstash"}, datatype=bool - ) - logstash_RW = AttributeWrapper( - comms_annotation={"container": "logstash"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - loki_R = AttributeWrapper(comms_annotation={"container": "loki"}, datatype=bool) - loki_RW = AttributeWrapper( - comms_annotation={"container": "loki"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - itango_R = AttributeWrapper(comms_annotation={"container": "itango"}, datatype=bool) - itango_RW = AttributeWrapper( - comms_annotation={"container": "itango"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - jupyter_lab_R = AttributeWrapper( - comms_annotation={"container": "jupyter-lab"}, datatype=bool - ) - jupyter_lab_RW = AttributeWrapper( - comms_annotation={"container": "jupyter-lab"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - tangodb_R = AttributeWrapper( - comms_annotation={"container": "tangodb"}, datatype=bool - ) - tangodb_RW = AttributeWrapper( - comms_annotation={"container": "tangodb"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - prometheus_R = AttributeWrapper( - comms_annotation={"container": "prometheus"}, datatype=bool - ) - prometheus_RW = AttributeWrapper( - comms_annotation={"container": "prometheus"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - tango_prometheus_exporter_R = AttributeWrapper( - comms_annotation={"container": "tango-prometheus-exporter"}, datatype=bool - ) - tango_prometheus_exporter_RW = AttributeWrapper( - comms_annotation={"container": "tango-prometheus-exporter"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - tango_prometheus_fast_exporter_R = AttributeWrapper( - comms_annotation={"container": "tango-prometheus-fast-exporter"}, datatype=bool - ) - tango_prometheus_fast_exporter_RW = AttributeWrapper( - comms_annotation={"container": "tango-prometheus-fast-exporter"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - prometheus_node_exporter_R = AttributeWrapper( - comms_annotation={"container": "prometheus-node-exporter"}, datatype=bool - ) - prometheus_node_exporter_RW = AttributeWrapper( - comms_annotation={"container": "prometheus-node-exporter"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - tango_rest_R = AttributeWrapper( - comms_annotation={"container": "tango-rest"}, datatype=bool - ) - tango_rest_RW = AttributeWrapper( - comms_annotation={"container": "tango-rest"}, - datatype=bool, - access=AttrWriteType.READ_WRITE, - ) - - # -------- - # overloaded functions - # -------- - @log_exceptions() - def configure_for_off(self): - """user code here. is called when the state is set to OFF""" - # Stop keep-alive - try: - self.docker_client.sync_stop() - except Exception as e: - logger.warning( - "Exception while stopping docker client in configure_for_off function: {}. Exception ignored".format( - e - ) - ) - - @log_exceptions() - def configure_for_initialise(self): - """user code here. is called when the state is set to INIT""" - - # set up the Docker client - self.docker_client = DockerClient(self.Docker_Base_URL, self.Fault) - - # schedule the docker initialisation, and wait for it to finish - future = asyncio.run_coroutine_threadsafe( - self._connect_docker(), self.docker_client.event_loop - ) - _ = future.result() - - async def _connect_docker(self): - # tie attributes to client - for i in self.attr_list(): - await i.async_set_comm_client(self, self.docker_client) - - await self.docker_client.start() - - # -------- - # Commands - # -------- diff --git a/tangostationcontrol/tangostationcontrol/devices/types.py b/tangostationcontrol/tangostationcontrol/devices/types.py index d6054a932a4b9abc0362588c3d3ba14fbb9fb2b7..4dfafb6e879fad61454dbbccc3923288c6fc9557 100644 --- a/tangostationcontrol/tangostationcontrol/devices/types.py +++ b/tangostationcontrol/tangostationcontrol/devices/types.py @@ -23,7 +23,6 @@ class DeviceTypes(str, Enum): CCD = "CCD" Configuration = "Configuration" DigitalBeam = "DigitalBeam" - Docker = "Docker" Observation = "Observation" ObservationControl = "ObservationControl" PCON = "PCON"