hammerkit 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeOrphanedContainers = exports.isProcessAlive = exports.isOrphanedContainer = void 0;
|
|
3
|
+
exports.removeOrphanedContainers = exports.isDockerUnreachable = exports.isProcessAlive = exports.isOrphanedContainer = void 0;
|
|
4
4
|
const os_1 = require("os");
|
|
5
5
|
const remove_container_1 = require("./remove-container");
|
|
6
6
|
// A hammerkit container nothing will remove any more: a task container (they
|
|
@@ -41,8 +41,26 @@ function isProcessAlive(pid) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
exports.isProcessAlive = isProcessAlive;
|
|
44
|
+
// No daemon listens on the socket or named pipe (ENOENT, or ECONNREFUSED for a
|
|
45
|
+
// socket nothing serves). Other failures, such as a permission error, are real.
|
|
46
|
+
function isDockerUnreachable(e) {
|
|
47
|
+
return e?.syscall === 'connect' && (e.code === 'ENOENT' || e.code === 'ECONNREFUSED');
|
|
48
|
+
}
|
|
49
|
+
exports.isDockerUnreachable = isDockerUnreachable;
|
|
50
|
+
// Without a Docker daemon there is no container left behind, so a machine that
|
|
51
|
+
// has none (a Windows runner without containers, a laptop with Docker stopped)
|
|
52
|
+
// cleans without error.
|
|
44
53
|
async function removeOrphanedContainers(docker) {
|
|
45
|
-
|
|
54
|
+
let containers;
|
|
55
|
+
try {
|
|
56
|
+
containers = await docker.listContainers({ all: true, filters: { label: ['app=hammerkit'] } });
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (isDockerUnreachable(e)) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
46
64
|
const orphaned = containers.filter((c) => isOrphanedContainer(c, isProcessAlive));
|
|
47
65
|
for (const container of orphaned) {
|
|
48
66
|
await (0, remove_container_1.removeContainer)(docker.getContainer(container.Id));
|
package/package.json
CHANGED