From 4bb504073d661eb53ece3e17600f721b87131c80 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Wed, 27 Nov 2024 23:39:17 +0200 Subject: [PATCH] Service installs: Avoid creating duplicate tasks on device registration Change-type: patch --- src/features/ci-cd/hooks/service-installs.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/features/ci-cd/hooks/service-installs.ts b/src/features/ci-cd/hooks/service-installs.ts index 9cf8d0a69..537978d83 100644 --- a/src/features/ci-cd/hooks/service-installs.ts +++ b/src/features/ci-cd/hooks/service-installs.ts @@ -260,6 +260,13 @@ hooks.addPureHook('POST', 'resin', 'device', { const app = request.values.belongs_to__application; if (app != null) { await createAppServiceInstalls(rootApi, app, [deviceId], tx); + if (ASYNC_TASKS_ENABLED && ASYNC_TASK_CREATE_SERVICE_INSTALLS_ENABLED) { + // When creating service installs via the async tasks, a single call to createServiceInstallsAsync() + // creates all service installs (target release, hostApp & SV release), so we don't need + // to run the extra code below to handle them separately, and doing so would create + // duplicate & unnecessary tasks. + return; + } } const release = request.values.is_pinned_on__release;