hammerkit 2.0.0-next.7 → 2.0.0-next.9
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/dist/kubernetes/await-running-state.js +69 -5
- package/dist/kubernetes/ensure-kubernetes-deployment-exists.js +10 -1
- package/dist/kubernetes/ensure-persistent-data.js +4 -5
- package/dist/kubernetes/follow-pod-logs.js +5 -3
- package/dist/kubernetes/quota-wait.js +97 -0
- package/dist/parser/read-build-file.js +8 -3
- package/dist/planner/utils/template-value.js +20 -4
- package/dist/planner/work-runtime-kubernetes.js +4 -1
- package/dist/schema/schema-parser.js +46 -2
- package/dist/server/capacity.js +10 -43
- package/dist/server/kubernetes-sandbox-storage.js +14 -4
- package/dist/server/sandbox-files.js +107 -16
- package/dist/server/sandbox-patch.js +43 -17
- package/dist/server/sandboxes.js +57 -23
- package/dist/server/sources.js +68 -11
- package/dist/utils/buffer-context.js +30 -20
- package/dist/utils/read-lines.js +65 -0
- package/dist/utils/units.js +36 -1
- package/package.json +1 -1
|
@@ -1,42 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BufferContext = void 0;
|
|
4
|
+
// The last `limit` entries of each id, and all of those in the order they came. An entry an id
|
|
5
|
+
// no longer keeps leaves both; the list of all of them drops what left now and then, so an
|
|
6
|
+
// entry costs the same however many ids there are.
|
|
4
7
|
class BufferContext {
|
|
5
8
|
constructor(limit) {
|
|
6
9
|
this.limit = limit;
|
|
7
|
-
this.scopedBuffer =
|
|
10
|
+
this.scopedBuffer = new Map();
|
|
8
11
|
this.buffer = [];
|
|
12
|
+
this.dropped = 0;
|
|
9
13
|
}
|
|
10
14
|
add(id, data) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const bufferIndex = this.buffer.indexOf(removedBuffer);
|
|
18
|
-
if (bufferIndex >= 0) {
|
|
19
|
-
this.buffer.splice(bufferIndex, 1);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
15
|
+
const entry = { data, kept: true };
|
|
16
|
+
this.buffer.push(entry);
|
|
17
|
+
let scopedBuffer = this.scopedBuffer.get(id);
|
|
18
|
+
if (!scopedBuffer) {
|
|
19
|
+
scopedBuffer = [];
|
|
20
|
+
this.scopedBuffer.set(id, scopedBuffer);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
scopedBuffer.push(entry);
|
|
23
|
+
if (scopedBuffer.length > this.limit) {
|
|
24
|
+
const removed = scopedBuffer.shift();
|
|
25
|
+
removed.kept = false;
|
|
26
|
+
this.dropped++;
|
|
27
|
+
if (this.dropped * 2 > this.buffer.length) {
|
|
28
|
+
this.compact();
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
current(id) {
|
|
28
|
-
|
|
33
|
+
const value = this.scopedBuffer.get(id);
|
|
34
|
+
if (!value || value.length === 0) {
|
|
29
35
|
return null;
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
return value[value.length - 1];
|
|
37
|
+
return value[value.length - 1].data;
|
|
33
38
|
}
|
|
34
39
|
get(id) {
|
|
35
40
|
if (id) {
|
|
36
|
-
return this.scopedBuffer
|
|
41
|
+
return (this.scopedBuffer.get(id) ?? []).map((entry) => entry.data);
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
this.compact();
|
|
44
|
+
return this.buffer.map((entry) => entry.data);
|
|
45
|
+
}
|
|
46
|
+
compact() {
|
|
47
|
+
if (this.dropped > 0) {
|
|
48
|
+
this.buffer = this.buffer.filter((entry) => entry.kept);
|
|
49
|
+
this.dropped = 0;
|
|
40
50
|
}
|
|
41
51
|
}
|
|
42
52
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readLines = void 0;
|
|
4
|
+
const string_decoder_1 = require("string_decoder");
|
|
5
|
+
/**
|
|
6
|
+
* Calls `onLine` with each line of `input` as readline does: a line ends at a line feed, a CR
|
|
7
|
+
* or both. It holds at most `maxChars` of a line: a longer line is cut there and says so, the
|
|
8
|
+
* rest of it up to the end of the line is passed over.
|
|
9
|
+
*/
|
|
10
|
+
function readLines(input, maxChars, onLine) {
|
|
11
|
+
const decoder = new string_decoder_1.StringDecoder('utf8');
|
|
12
|
+
let pending = '';
|
|
13
|
+
let cut = false;
|
|
14
|
+
// the last line ended with a CR, so a line feed right after it ends no other line
|
|
15
|
+
let afterCr = false;
|
|
16
|
+
const emit = () => {
|
|
17
|
+
onLine(cut ? `${pending} … [cut at ${maxChars} characters]` : pending);
|
|
18
|
+
pending = '';
|
|
19
|
+
cut = false;
|
|
20
|
+
};
|
|
21
|
+
const take = (text) => {
|
|
22
|
+
let start = 0;
|
|
23
|
+
if (afterCr && text.length > 0) {
|
|
24
|
+
afterCr = false;
|
|
25
|
+
if (text[0] === '\n') {
|
|
26
|
+
start = 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const ends = /[\r\n]/g;
|
|
30
|
+
for (;;) {
|
|
31
|
+
ends.lastIndex = start;
|
|
32
|
+
const end = ends.exec(text);
|
|
33
|
+
if (!cut) {
|
|
34
|
+
pending += text.slice(start, end ? end.index : undefined);
|
|
35
|
+
if (pending.length > maxChars) {
|
|
36
|
+
pending = pending.slice(0, maxChars);
|
|
37
|
+
cut = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!end) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
emit();
|
|
44
|
+
start = end.index + 1;
|
|
45
|
+
if (end[0] === '\r') {
|
|
46
|
+
if (start === text.length) {
|
|
47
|
+
afterCr = true;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (text[start] === '\n') {
|
|
51
|
+
start++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
input.on('data', (chunk) => take(typeof chunk === 'string' ? chunk : decoder.write(chunk)));
|
|
57
|
+
input.on('end', () => {
|
|
58
|
+
take(decoder.end());
|
|
59
|
+
if (pending.length > 0 || cut) {
|
|
60
|
+
emit();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.readLines = readLines;
|
|
65
|
+
//# sourceMappingURL=read-lines.js.map
|
package/dist/utils/units.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCpus = exports.formatSize = exports.parseSize = exports.formatDuration = exports.parseDuration = void 0;
|
|
3
|
+
exports.parseQuantity = exports.parseCpus = exports.formatSize = exports.parseSize = exports.formatDuration = exports.parseDuration = void 0;
|
|
4
4
|
const DURATION_UNITS = {
|
|
5
5
|
ms: 1,
|
|
6
6
|
s: 1000,
|
|
@@ -97,4 +97,39 @@ function parseCpus(value) {
|
|
|
97
97
|
return millicores / 1000;
|
|
98
98
|
}
|
|
99
99
|
exports.parseCpus = parseCpus;
|
|
100
|
+
const QUANTITY_UNITS = {
|
|
101
|
+
n: 1e-9,
|
|
102
|
+
u: 1e-6,
|
|
103
|
+
m: 1e-3,
|
|
104
|
+
'': 1,
|
|
105
|
+
k: 1e3,
|
|
106
|
+
K: 1e3,
|
|
107
|
+
M: 1e6,
|
|
108
|
+
G: 1e9,
|
|
109
|
+
T: 1e12,
|
|
110
|
+
P: 1e15,
|
|
111
|
+
E: 1e18,
|
|
112
|
+
Ki: 1024,
|
|
113
|
+
Mi: 1024 ** 2,
|
|
114
|
+
Gi: 1024 ** 3,
|
|
115
|
+
Ti: 1024 ** 4,
|
|
116
|
+
Pi: 1024 ** 5,
|
|
117
|
+
Ei: 1024 ** 6,
|
|
118
|
+
};
|
|
119
|
+
// A quantity of Kubernetes (`250m`, `1.5`, `512Mi`, `12345678n`, `1e3`), as a number.
|
|
120
|
+
function parseQuantity(value) {
|
|
121
|
+
if (value === undefined) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (typeof value === 'number') {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
const match = /^([+-]?[0-9.]+(?:[eE][+-]?\d+)?)([a-zA-Z]*)$/.exec(value.trim());
|
|
128
|
+
if (!match || !(match[2] in QUANTITY_UNITS)) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
const number = Number(match[1]);
|
|
132
|
+
return Number.isFinite(number) ? number * QUANTITY_UNITS[match[2]] : undefined;
|
|
133
|
+
}
|
|
134
|
+
exports.parseQuantity = parseQuantity;
|
|
100
135
|
//# sourceMappingURL=units.js.map
|
package/package.json
CHANGED