Skip to content

Commit e7838a9

Browse files
committed
var-update-trigger: Update only devices that should be running the release that the image env var is part of
Change-type: patch
1 parent f9eb84b commit e7838a9

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

src/features/vars-schema/hooks/vars-update-trigger.ts

+22-28
Original file line numberDiff line numberDiff line change
@@ -316,24 +316,26 @@ addEnvHooks('device_service_environment_variable', async (args) => {
316316
];
317317
});
318318

319+
// Normally we don't expect these to return any match, since our clients
320+
// * POST image env vars before the release & images gets marked as successful
321+
// * never PATCH them after that point
322+
// * DELETEs are expected to normally only happen if the release gets DELETED,
323+
// in which case the should_be_running__release will change and trigger an update of its own.
319324
addEnvHooks('image_environment_variable', async (args) => {
325+
// The filter paths here should match the expand path of the state GET.
320326
if (args.req.body.release_image != null) {
321327
return {
322-
image_install: {
328+
should_be_running__release: {
323329
$any: {
324-
$alias: 'ii',
330+
$alias: 'r',
325331
$expr: {
326-
installs__image: {
332+
status: 'success',
333+
release_image: {
327334
$any: {
328-
$alias: 'i',
335+
$alias: 'ri',
329336
$expr: {
330-
i: {
331-
release_image: {
332-
$any: {
333-
$alias: 'ri',
334-
$expr: { ri: { id: args.req.body.release_image } },
335-
},
336-
},
337+
ri: {
338+
id: args.req.body.release_image,
337339
},
338340
},
339341
},
@@ -351,28 +353,20 @@ addEnvHooks('image_environment_variable', async (args) => {
351353
return [
352354
envVarIds,
353355
(envVarIdsChunk) => ({
354-
image_install: {
356+
should_be_running__release: {
355357
$any: {
356-
$alias: 'ii',
358+
$alias: 'r',
357359
$expr: {
358-
installs__image: {
360+
status: 'success',
361+
release_image: {
359362
$any: {
360-
$alias: 'i',
363+
$alias: 'ri',
361364
$expr: {
362-
i: {
363-
release_image: {
365+
ri: {
366+
image_environment_variable: {
364367
$any: {
365-
$alias: 'ri',
366-
$expr: {
367-
ri: {
368-
image_environment_variable: {
369-
$any: {
370-
$alias: 'e',
371-
$expr: { e: { id: { $in: envVarIdsChunk } } },
372-
},
373-
},
374-
},
375-
},
368+
$alias: 'e',
369+
$expr: { e: { id: { $in: envVarIdsChunk } } },
376370
},
377371
},
378372
},

0 commit comments

Comments
 (0)