From a13ed02207e2174e5632918c9f54d637be06756f Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Thu, 17 Oct 2024 13:06:40 +0300 Subject: [PATCH] Skip triggering device update checks for image env var POSTs of non-successful releases Change-type: patch --- .../vars-schema/hooks/vars-update-trigger.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/features/vars-schema/hooks/vars-update-trigger.ts b/src/features/vars-schema/hooks/vars-update-trigger.ts index 019fe461d..f5dca8565 100644 --- a/src/features/vars-schema/hooks/vars-update-trigger.ts +++ b/src/features/vars-schema/hooks/vars-update-trigger.ts @@ -318,6 +318,30 @@ addEnvHooks('device_service_environment_variable', async (args) => { addEnvHooks('image_environment_variable', async (args) => { if (args.req.body.release_image != null) { + const isPartOfSuccessfulRelease = + (await args.api.get({ + resource: 'release_image', + id: args.req.body.release_image, + options: { + $select: 'id', + $filter: { + is_part_of__release: { + $any: { + $alias: 'r', + $expr: { + r: { + status: 'success', + }, + }, + }, + }, + }, + }, + })) != null; + if (!isPartOfSuccessfulRelease) { + return; + } + return { image_install: { $any: {