docker-storage-gc 3.5.6 → 3.5.7
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.
- package/.versionbot/CHANGELOG.yml +12 -1
- package/CHANGELOG.md +5 -0
- package/build/docker-event-stream.js +3 -3
- package/build/docker-image-tree.js +3 -3
- package/build/docker.js +5 -5
- package/build/index.js +6 -6
- package/lib/docker-event-stream.coffee +2 -2
- package/lib/docker-image-tree.coffee +2 -2
- package/lib/docker.coffee +3 -3
- package/lib/index.coffee +5 -5
- package/package.json +2 -2
- package/test/docker-event-stream.coffee +0 -1
- package/test/docker-image-tree.coffee +0 -1
- package/test/index.coffee +10 -10
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: Import bluebird as `Bluebird` instead of `Promise`
|
|
3
|
+
hash: f97bfe4be10415ff3a74709d1c158eb847a280d1
|
|
4
|
+
body: ""
|
|
5
|
+
footer:
|
|
6
|
+
Change-type: patch
|
|
7
|
+
change-type: patch
|
|
8
|
+
author: Pagan Gazzard
|
|
9
|
+
version: 3.5.7
|
|
10
|
+
title: ""
|
|
11
|
+
date: 2023-11-28T22:06:48.856Z
|
|
1
12
|
- commits:
|
|
2
13
|
- subject: Remove unused `mz` dependency
|
|
3
14
|
hash: b39c411f82f69b7aa980364bce04e8b398a343da
|
|
@@ -8,7 +19,7 @@
|
|
|
8
19
|
author: Pagan Gazzard
|
|
9
20
|
version: 3.5.6
|
|
10
21
|
title: ""
|
|
11
|
-
date: 2023-11-28T20:
|
|
22
|
+
date: 2023-11-28T20:47:13.918Z
|
|
12
23
|
- commits:
|
|
13
24
|
- subject: add support for arm32 architecture
|
|
14
25
|
hash: d308f7ad8e13c0d34960328c58e18715acb70aaf
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
# v3.5.7
|
|
8
|
+
## (2023-11-28)
|
|
9
|
+
|
|
10
|
+
* Import bluebird as `Bluebird` instead of `Promise` [Pagan Gazzard]
|
|
11
|
+
|
|
7
12
|
# v3.5.6
|
|
8
13
|
## (2023-11-28)
|
|
9
14
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Generated by CoffeeScript 1.12.7
|
|
2
2
|
(function() {
|
|
3
|
-
var CONTAINER_EVENTS, IMAGE_EVENTS, JSONStream,
|
|
3
|
+
var Bluebird, CONTAINER_EVENTS, IMAGE_EVENTS, JSONStream, es, parseEventStream,
|
|
4
4
|
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Bluebird = require('bluebird');
|
|
7
7
|
|
|
8
8
|
es = require('event-stream');
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
exports.dockerMtimeStream = function(docker) {
|
|
46
|
-
return
|
|
46
|
+
return Bluebird.join(docker.getEvents(), parseEventStream(docker), function(stream, streamParser) {
|
|
47
47
|
return es.pipeline(stream, streamParser);
|
|
48
48
|
});
|
|
49
49
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Generated by CoffeeScript 1.12.7
|
|
2
2
|
(function() {
|
|
3
|
-
var
|
|
3
|
+
var Bluebird, _, createNode, createTree, getMtime, getMtimeFrom, saneRepoAttrs,
|
|
4
4
|
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
|
5
5
|
|
|
6
6
|
_ = require('lodash');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Bluebird = require('bluebird');
|
|
9
9
|
|
|
10
10
|
saneRepoAttrs = function(repoAttrs) {
|
|
11
11
|
if (repoAttrs == null) {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
exports.dockerImageTree = function(docker, layer_mtimes) {
|
|
76
|
-
return
|
|
76
|
+
return Bluebird.join(docker.listImages({
|
|
77
77
|
all: true
|
|
78
78
|
}), docker.listContainers({
|
|
79
79
|
all: true
|
package/build/docker.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// Generated by CoffeeScript 1.12.7
|
|
2
2
|
(function() {
|
|
3
|
-
var
|
|
3
|
+
var Bluebird, Docker, _, getDockerConnectOpts;
|
|
4
4
|
|
|
5
5
|
Docker = require('dockerode');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Bluebird = require('bluebird');
|
|
8
8
|
|
|
9
9
|
_ = require('lodash');
|
|
10
10
|
|
|
11
11
|
getDockerConnectOpts = function(hostObj) {
|
|
12
12
|
if (!_.isEmpty(hostObj)) {
|
|
13
|
-
return
|
|
13
|
+
return Bluebird.resolve(hostObj);
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return Bluebird.resolve({
|
|
16
16
|
socketPath: '/var/run/docker.sock',
|
|
17
|
-
Promise:
|
|
17
|
+
Promise: Bluebird
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
package/build/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Generated by CoffeeScript 1.12.7
|
|
2
2
|
(function() {
|
|
3
|
-
var Docker, DockerGC, DockerProgress, EventEmitter,
|
|
3
|
+
var Bluebird, Docker, DockerGC, DockerProgress, EventEmitter, _, dockerImageTree, dockerMtimeStream, dockerUtils, getImagesToRemove, getUnusedTreeLeafs, recordGcRunTime, streamToString,
|
|
4
4
|
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Bluebird = require('bluebird');
|
|
7
7
|
|
|
8
8
|
_ = require('lodash');
|
|
9
9
|
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
streamToString = function(stream) {
|
|
63
|
-
return new
|
|
63
|
+
return new Bluebird(function(resolve, reject) {
|
|
64
64
|
var chunks;
|
|
65
65
|
chunks = [];
|
|
66
66
|
return stream.on('error', reject).on('data', function(chunk) {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
DockerGC.prototype.setDocker = function(hostObj) {
|
|
95
95
|
this.currentMtimes = {};
|
|
96
96
|
this.hostObj = _.defaults({
|
|
97
|
-
Promise:
|
|
97
|
+
Promise: Bluebird
|
|
98
98
|
}, hostObj);
|
|
99
99
|
this.dockerProgress = new DockerProgress({
|
|
100
100
|
docker: new Docker(this.hostObj)
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
|
|
135
135
|
DockerGC.prototype.tryRemoveImageBy = function(image, attributes, removalType) {
|
|
136
136
|
if ((attributes != null) && attributes.length > 0) {
|
|
137
|
-
return
|
|
137
|
+
return Bluebird.each(attributes, (function(_this) {
|
|
138
138
|
return function(attribute) {
|
|
139
139
|
console.log("[GC (" + _this.host + "] Removing image : " + attribute + " (id: " + image.id + ")");
|
|
140
140
|
return _this.docker.getImage(attribute).remove({
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
DockerGC.prototype.getOutput = function(image, command) {
|
|
187
|
-
return
|
|
187
|
+
return Bluebird.using(this.runDisposer(image, command), function(container) {
|
|
188
188
|
return container.logs({
|
|
189
189
|
stdout: true,
|
|
190
190
|
follow: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Bluebird = require 'bluebird'
|
|
2
2
|
es = require 'event-stream'
|
|
3
3
|
JSONStream = require 'JSONStream'
|
|
4
4
|
|
|
@@ -35,7 +35,7 @@ exports.parseEventStream = parseEventStream = (docker) ->
|
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
exports.dockerMtimeStream = (docker) ->
|
|
38
|
-
|
|
38
|
+
Bluebird.join(
|
|
39
39
|
docker.getEvents()
|
|
40
40
|
parseEventStream(docker)
|
|
41
41
|
(stream, streamParser) ->
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
_ = require 'lodash'
|
|
2
|
-
|
|
2
|
+
Bluebird = require 'bluebird'
|
|
3
3
|
|
|
4
4
|
saneRepoAttrs = (repoAttrs) ->
|
|
5
5
|
return [] if !repoAttrs?
|
|
@@ -48,7 +48,7 @@ exports.createTree = createTree = (images, containers, layer_mtimes) ->
|
|
|
48
48
|
return tree[root]
|
|
49
49
|
|
|
50
50
|
exports.dockerImageTree = (docker, layer_mtimes) ->
|
|
51
|
-
|
|
51
|
+
Bluebird.join(
|
|
52
52
|
docker.listImages(all: true)
|
|
53
53
|
docker.listContainers(all: true)
|
|
54
54
|
layer_mtimes
|
package/lib/docker.coffee
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Docker = require 'dockerode'
|
|
2
|
-
|
|
2
|
+
Bluebird = require 'bluebird'
|
|
3
3
|
_ = require 'lodash'
|
|
4
4
|
|
|
5
5
|
getDockerConnectOpts = (hostObj) ->
|
|
6
6
|
if !_.isEmpty(hostObj)
|
|
7
|
-
return
|
|
8
|
-
return
|
|
7
|
+
return Bluebird.resolve(hostObj)
|
|
8
|
+
return Bluebird.resolve({ socketPath: '/var/run/docker.sock', Promise: Bluebird })
|
|
9
9
|
|
|
10
10
|
exports.getDocker = (hostObj) ->
|
|
11
11
|
getDockerConnectOpts(hostObj)
|
package/lib/index.coffee
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Bluebird = require 'bluebird'
|
|
2
2
|
_ = require 'lodash'
|
|
3
3
|
{ EventEmitter } = require 'eventemitter3'
|
|
4
4
|
|
|
@@ -47,7 +47,7 @@ getImagesToRemove = (tree, reclaimSpace, metrics) ->
|
|
|
47
47
|
return result
|
|
48
48
|
|
|
49
49
|
streamToString = (stream) ->
|
|
50
|
-
new
|
|
50
|
+
new Bluebird (resolve, reject) ->
|
|
51
51
|
chunks = []
|
|
52
52
|
stream
|
|
53
53
|
.on('error', reject)
|
|
@@ -72,7 +72,7 @@ class DockerGC
|
|
|
72
72
|
|
|
73
73
|
setDocker: (hostObj) ->
|
|
74
74
|
@currentMtimes = {}
|
|
75
|
-
@hostObj = _.defaults({ Promise }, hostObj)
|
|
75
|
+
@hostObj = _.defaults({ Promise: Bluebird }, hostObj)
|
|
76
76
|
@dockerProgress = new DockerProgress({ docker: new Docker(@hostObj) })
|
|
77
77
|
dockerUtils.getDocker(@hostObj)
|
|
78
78
|
.then (@docker) =>
|
|
@@ -101,7 +101,7 @@ class DockerGC
|
|
|
101
101
|
|
|
102
102
|
tryRemoveImageBy: (image, attributes, removalType) =>
|
|
103
103
|
if attributes? and attributes.length > 0
|
|
104
|
-
|
|
104
|
+
Bluebird.each attributes, (attribute) =>
|
|
105
105
|
console.log("[GC (#{@host}] Removing image : #{attribute} (id: #{image.id})")
|
|
106
106
|
@docker.getImage(attribute).remove(noprune: true)
|
|
107
107
|
.then =>
|
|
@@ -131,7 +131,7 @@ class DockerGC
|
|
|
131
131
|
throw err
|
|
132
132
|
|
|
133
133
|
getOutput: (image, command) ->
|
|
134
|
-
|
|
134
|
+
Bluebird.using @runDisposer(image, command), (container) ->
|
|
135
135
|
container.logs(stdout: true, follow: true)
|
|
136
136
|
.then (logs) ->
|
|
137
137
|
streamToString(logs)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docker-storage-gc",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.7",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"timekeeper": "0.0.5"
|
|
33
33
|
},
|
|
34
34
|
"versionist": {
|
|
35
|
-
"publishedAt": "2023-11-
|
|
35
|
+
"publishedAt": "2023-11-28T22:06:48.959Z"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/test/index.coffee
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Bluebird = require 'bluebird'
|
|
2
2
|
{ expect } = require 'chai'
|
|
3
3
|
|
|
4
4
|
DockerGC = require('../lib/index')
|
|
@@ -31,14 +31,14 @@ describe 'Garbage collection', ->
|
|
|
31
31
|
beforeEach ->
|
|
32
32
|
@dockerStorage = new DockerGC()
|
|
33
33
|
# Use either local or CI docker
|
|
34
|
-
|
|
34
|
+
Bluebird.join(
|
|
35
35
|
dockerUtils.getDocker({
|
|
36
36
|
socketPath: '/tmp/dind/docker.sock',
|
|
37
|
-
Promise,
|
|
37
|
+
Promise: Bluebird,
|
|
38
38
|
})
|
|
39
39
|
@dockerStorage.setDocker({
|
|
40
40
|
socketPath: '/tmp/dind/docker.sock',
|
|
41
|
-
Promise,
|
|
41
|
+
Promise: Bluebird,
|
|
42
42
|
})
|
|
43
43
|
(docker) =>
|
|
44
44
|
@dockerStorage.setupMtimeStream()
|
|
@@ -87,14 +87,14 @@ describe 'Garbage collection', ->
|
|
|
87
87
|
docker = @docker
|
|
88
88
|
dockerStorage = @dockerStorage
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
Bluebird.each NONE_TAG_IMAGES, (image) ->
|
|
91
91
|
pullAsync(docker, image)
|
|
92
92
|
.then ->
|
|
93
93
|
docker.getImage(NONE_TAG_IMAGES[0]).inspect()
|
|
94
94
|
.then ->
|
|
95
95
|
dockerStorage.garbageCollect(1)
|
|
96
96
|
.then ->
|
|
97
|
-
|
|
97
|
+
Bluebird.map NONE_TAG_IMAGES, (image) ->
|
|
98
98
|
promiseToBool(docker.getImage(image).inspect())
|
|
99
99
|
.then (imagesFound) ->
|
|
100
100
|
expect(imagesFound).to.deep.equal([false, false])
|
|
@@ -129,14 +129,14 @@ describe 'Garbage collection', ->
|
|
|
129
129
|
.then ->
|
|
130
130
|
docker.getImage(IMAGES[0]).tag(repo: 'some-repo', tag: 'some-tag')
|
|
131
131
|
.then ->
|
|
132
|
-
|
|
132
|
+
Bluebird.each IMAGES.slice(1), (image) ->
|
|
133
133
|
pullAsync(docker, image)
|
|
134
134
|
.then =>
|
|
135
135
|
# Attempt to remove a single byte, which will remove the LRU image,
|
|
136
136
|
# which should be alpine
|
|
137
137
|
@dockerStorage.garbageCollect(1)
|
|
138
138
|
.then ->
|
|
139
|
-
|
|
139
|
+
Bluebird.map IMAGES, (image) ->
|
|
140
140
|
promiseToBool(docker.getImage(image).inspect())
|
|
141
141
|
.then (imagesFound) ->
|
|
142
142
|
expect(imagesFound).to.deep.equal([false, true, true])
|
|
@@ -147,7 +147,7 @@ describe 'Garbage collection', ->
|
|
|
147
147
|
|
|
148
148
|
docker = @docker
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
Bluebird.each IMAGES, (image) ->
|
|
151
151
|
pullAsync(docker, image)
|
|
152
152
|
.then ->
|
|
153
153
|
# Get the size of the first image, so we can add one to it to remove
|
|
@@ -156,7 +156,7 @@ describe 'Garbage collection', ->
|
|
|
156
156
|
.then (size) =>
|
|
157
157
|
@dockerStorage.garbageCollect(size + 1)
|
|
158
158
|
.then ->
|
|
159
|
-
|
|
159
|
+
Bluebird.map IMAGES, (image) ->
|
|
160
160
|
promiseToBool(docker.getImage(image).inspect())
|
|
161
161
|
.then (imagesFound) ->
|
|
162
162
|
expect(imagesFound).to.deep.equal([false, false, true])
|