From d12b6d87ce25c718cd0df136b66087ecbf013c2d Mon Sep 17 00:00:00 2001 From: kzangeli Date: Thu, 29 Oct 2026 18:41:31 +0100 Subject: [PATCH] IoT Agent memory and tutorial clean-up: one agent worker, no retried creates, services stop removes only the tutorial's - IoT Agent: `IOTA_MULTI_CORE=false`. With `true` the agent forks one worker per *host* CPU core, although the container is limited to 2 CPUs and 1 GiB. On a 32-core machine an idle agent already uses 972 MiB and is killed for running out of memory (83 MiB with `false`). A provisioning request then gets an empty reply and the `services` start fails. - No retry on the device and service-group POSTs. `--retry-all-errors` repeats a create that has already reached the IoT Agent. Every retry is then a 409, and a batch that was only partly created is never completed. `services` already waits for the agent to be healthy before these requests. - `services stop` removes only the tutorial's containers, volumes and networks. It removed *every* container on the machine (`docker rm -f $(docker ps -aq)`) and every unused volume (`docker volume ls -qf dangling=true`), the user's own included. Now: the containers labelled `org.fiware=tutorial`, with their anonymous volumes (`rm -v`); the unused volumes of the `fiware` compose project; the tutorial's networks. Co-Authored-By: Claude Opus 5.5 --- docker-compose/common.yml | 2 +- link-devices | 4 ++-- provision-devices | 10 +++++----- services | 19 +++++++++---------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/docker-compose/common.yml b/docker-compose/common.yml index a23b7f8..240c710 100644 --- a/docker-compose/common.yml +++ b/docker-compose/common.yml @@ -106,7 +106,7 @@ services: - IOTA_CB_NGSI_VERSION=ld # use NGSI-LD when sending updates for active attributes - IOTA_JSON_LD_CONTEXT=http://context/user-context.jsonld - IOTA_FALLBACK_TENANT=openiot - - IOTA_MULTI_CORE=true + - IOTA_MULTI_CORE=false - IOTA_AMQP_DISABLED=true - IOTA_MQTT_DISABLED=true healthcheck: diff --git a/link-devices b/link-devices index 38d8057..568eccb 100644 --- a/link-devices +++ b/link-devices @@ -42,7 +42,7 @@ do fi done -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ @@ -74,7 +74,7 @@ do fi done -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ diff --git a/provision-devices b/provision-devices index 10de26a..8ed333d 100755 --- a/provision-devices +++ b/provision-devices @@ -17,7 +17,7 @@ printf "⏳ Provisioning IoT devices " # Create a service groups for all JSON IoT devices # -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/services' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ @@ -170,7 +170,7 @@ curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ # Provision actuators for Farm 001 # -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ @@ -226,7 +226,7 @@ curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ # Provision actuators for Farm 002 # -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ @@ -282,7 +282,7 @@ curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ # Provision actuators for Farm 003 # -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ @@ -338,7 +338,7 @@ curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ # Provision actuators for Farm 004 # -curl -sSf -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ +curl -sSf -o /dev/null -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ diff --git a/services b/services index 5863a5f..f4ffdc1 100755 --- a/services +++ b/services @@ -157,22 +157,21 @@ loadData () { } stoppingContainers () { - CONTAINERS=$(docker ps -aq) + CONTAINERS=$(docker ps --filter "label=org.fiware=tutorial" -aq) if [[ -n "$CONTAINERS" ]]; then echo "Stopping containers" - # docker rm -f $CONTAINERS - ${dockerCmd} -f docker-compose/common.yml \ - -f docker-compose/scorpio.yml \ - -f docker-compose/orion-ld.yml \ - -f docker-compose/stellio.yml \ - -p fiware down --remove-orphans + docker rm -f -v $CONTAINERS || true fi - VOLUMES=$(docker volume ls -qf dangling=true) + VOLUMES=$(docker volume ls -q --filter dangling=true --filter "label=com.docker.compose.project=fiware") if [[ -n "$VOLUMES" ]]; then echo "Removing old volumes" - docker volume rm $VOLUMES + docker volume rm $VOLUMES || true + fi + NETWORKS=$(docker network ls --filter "label=org.fiware=tutorial" -q) + if [[ -n "$NETWORKS" ]]; then + echo "Removing tutorial networks" + docker network rm $NETWORKS || true fi - } displayServices () {