docker: prune volumes on infra change

This commit is contained in:
Girish Ramakrishnan
2024-04-04 11:36:04 +02:00
parent 68724bcb4f
commit 030e468829
+11 -1
View File
@@ -75,6 +75,13 @@ async function pruneInfraImages() {
}
}
async function pruneVolumes() {
debug('pruneVolumes: remove all unused local volumes');
const [error] = await safe(shell.execArgs('pruneVolumes', 'docker', [ 'volume', 'prune', '--all', '--force' ], {}));
if (error) console.log(`Error pruning volumes: ${error.mesage}`);
}
async function createDockerNetwork() {
debug('createDockerNetwork: recreating docker network');
@@ -122,7 +129,10 @@ async function onInfraReady(infraChanged) {
debug(`onInfraReady: platform is ready. infra changed: ${infraChanged}`);
gStatusMessage = 'Ready';
if (infraChanged) await safe(pruneInfraImages(), { debug }); // ignore error
if (infraChanged) {
await safe(pruneInfraImages(), { debug }); // ignore error
await safe(pruneVolumes(), { debug }); // ignore error
}
await apps.schedulePendingTasks(AuditSource.PLATFORM);
}