Fix target state construction with livepush

When constructing the target state after a reported change from livepush, the
handler function would not pass all build tasks to the function that
constructs the target state, causing a TypeError when trying to obtain
the target image name for each service. This updates the handler to pass
all build tasks, ensuring the information is available to construct the
target state.

Relates-to: #2724
Change-type: patch
This commit is contained in:
Felipe Lalanne 2024-01-30 11:03:37 -03:00
parent 4b2602676b
commit 8d6a621bfb
2 changed files with 10 additions and 12 deletions

View File

@ -627,17 +627,10 @@ export function generateTargetState(
};
opts.environment = _.merge(opts.environment, env[name]);
// This function can be called with a subset of the
// build tasks, when a single dockerfile has changed
// when livepushing, so check the build task exists for
// this composition entry (everything else in this
// function comes from the composition which doesn't
// change)
let contract;
if (name in keyedBuildTasks) {
contract = keyedBuildTasks[name].contract;
}
// This function should always be called with all the build tasks
// so we can construct the correct target state so we don't really need
// to check that the key exists on the `keyedBuildTasks` object
const contract = keyedBuildTasks[name].contract;
const task = keyedBuildTasks[name];
services[idx] = {

View File

@ -423,7 +423,12 @@ export class LivepushManager {
// If we re-apply the target state, the supervisor
// should recreate the container
await this.api.setTargetState(
generateTargetState(currentState, this.composition, [buildTask], {}),
generateTargetState(
currentState,
this.composition,
this.buildTasks,
{},
),
);
await this.awaitDeviceStateSettle();