Skip to content

Commit

Permalink
Merge pull request #2226 from balena-os/sandbox-error
Browse files Browse the repository at this point in the history
Force remove container if updateMetadata fails
  • Loading branch information
flowzone-app[bot] authored Nov 22, 2023
2 parents 6acd04a + 3ea8d47 commit 698b815
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/compose/service-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,20 @@ export async function updateMetadata(service: Service, target: Service) {
);
}

await docker.getContainer(svc.containerId).rename({
name: `${service.serviceName}_${target.imageId}_${target.releaseId}_${target.commit}`,
});
try {
await docker.getContainer(svc.containerId).rename({
name: `${service.serviceName}_${target.imageId}_${target.releaseId}_${target.commit}`,
});
} catch (e) {
if (isNotFoundError(e)) {
log.warn(
'Got 404 error while updating container metadata. Will attempt to recreate the container instead',
e,
);
return await docker.getContainer(svc.containerId).remove({ force: true });
}
throw e;
}
}

export async function handover(current: Service, target: Service) {
Expand Down

0 comments on commit 698b815

Please sign in to comment.