hammerkit 2.1.0-next.2 → 2.1.0-next.20

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.
Files changed (87) hide show
  1. package/build.schema.json +39 -18
  2. package/dist/cli.js +5 -0
  3. package/dist/dashboard/assets/graph-canvas-D6GMgkoe.js +8 -0
  4. package/dist/dashboard/assets/index-BNq9j5Jo.js +23 -0
  5. package/dist/dashboard/assets/index-DP3_hKOe.css +2 -0
  6. package/dist/dashboard/index.html +2 -2
  7. package/dist/environment/replace-env-variables.js +8 -5
  8. package/dist/environment/run-source-envs.js +2 -1
  9. package/dist/executer/archive-task-entry.js +1 -1
  10. package/dist/executer/deadline.js +63 -10
  11. package/dist/executer/event-cache.js +5 -1
  12. package/dist/executer/execute-work-task.js +15 -3
  13. package/dist/executer/runner-commands.js +36 -0
  14. package/dist/file/get-file-context.js +4 -7
  15. package/dist/harness/connect.js +12 -8
  16. package/dist/harness/reconnect.js +141 -0
  17. package/dist/harness/sandbox-client.js +159 -30
  18. package/dist/harness/service-tools.js +11 -2
  19. package/dist/kubernetes/cluster-state.js +48 -14
  20. package/dist/kubernetes/ensure-persistent-data.js +15 -4
  21. package/dist/kubernetes/follow-pod-logs.js +8 -5
  22. package/dist/kubernetes/kept-claims.js +26 -5
  23. package/dist/kubernetes/resources.js +5 -1
  24. package/dist/kubernetes/sandbox-runner.js +526 -156
  25. package/dist/kubernetes/store-kubernetes-data.js +18 -3
  26. package/dist/kubernetes/sync-changes.js +463 -0
  27. package/dist/kubernetes/volumes.js +23 -1
  28. package/dist/optimizer/get-work-cache-stats.js +7 -0
  29. package/dist/optimizer/work-task-cache-description.js +3 -2
  30. package/dist/planner/image-build.js +5 -0
  31. package/dist/planner/utils/dependency-outputs.js +7 -6
  32. package/dist/planner/validate.js +41 -0
  33. package/dist/planner/work-item-status.js +12 -2
  34. package/dist/planner/work-runtime-aggregate.js +1 -0
  35. package/dist/planner/work-runtime-docker.js +33 -6
  36. package/dist/planner/work-runtime-kubernetes.js +313 -70
  37. package/dist/planner/work-runtime-local.js +8 -4
  38. package/dist/planner/work-secret.js +33 -11
  39. package/dist/planner/work-service-id.js +30 -6
  40. package/dist/program.js +19 -1
  41. package/dist/remote/annotations.js +37 -5
  42. package/dist/remote/bundle.js +6 -8
  43. package/dist/remote/collect-bundle.js +3 -2
  44. package/dist/remote/device-login.js +4 -1
  45. package/dist/remote/remote-commands.js +16 -7
  46. package/dist/remote/remote-work-commands.js +266 -75
  47. package/dist/remote/server-client.js +38 -40
  48. package/dist/schema/build-file-base-task-schema.js +16 -1
  49. package/dist/schema/build-file-image-build-schema.js +5 -8
  50. package/dist/schema/reference-parser.js +108 -43
  51. package/dist/schema/work-scope-parser.js +8 -0
  52. package/dist/secrets/prefetch-secrets.js +20 -1
  53. package/dist/server/artifacts-api.js +56 -0
  54. package/dist/server/definitions-api.js +62 -8
  55. package/dist/server/executor.js +117 -30
  56. package/dist/server/http.js +4 -1
  57. package/dist/server/keep-artifacts.js +230 -0
  58. package/dist/server/kubernetes-backend.js +186 -59
  59. package/dist/server/kubernetes-sandbox-storage.js +3 -2
  60. package/dist/server/overview.js +73 -9
  61. package/dist/server/paging.js +167 -0
  62. package/dist/server/plan.js +16 -1
  63. package/dist/server/run-access.js +24 -0
  64. package/dist/server/run-artifacts.js +171 -0
  65. package/dist/server/run-logs.js +25 -1
  66. package/dist/server/run-request.js +11 -0
  67. package/dist/server/run-source-environment.js +1 -1
  68. package/dist/server/run-worker.js +267 -33
  69. package/dist/server/runs.js +527 -99
  70. package/dist/server/sandbox-files-api.js +27 -12
  71. package/dist/server/sandbox-files.js +12 -10
  72. package/dist/server/sandbox-follow.js +54 -0
  73. package/dist/server/sandbox-pod.js +1 -1
  74. package/dist/server/sandbox-storage.js +38 -1
  75. package/dist/server/sandbox-sync.js +392 -0
  76. package/dist/server/sandboxes-api.js +116 -19
  77. package/dist/server/sandboxes.js +38 -3
  78. package/dist/server/server-config.js +14 -0
  79. package/dist/server/server.js +169 -38
  80. package/dist/server/task-order.js +56 -0
  81. package/dist/utils/project-path.js +20 -0
  82. package/dist/utils/tar-files.js +52 -0
  83. package/dist/utils/tar.js +37 -1
  84. package/package.json +1 -1
  85. package/dist/dashboard/assets/graph-canvas-DtJSpova.js +0 -8
  86. package/dist/dashboard/assets/index-BndChMep.css +0 -2
  87. package/dist/dashboard/assets/index-DRSwIRXd.js +0 -17
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tarFiles = void 0;
4
+ const tar_1 = require("tar");
5
+ const path_1 = require("path");
6
+ const BLOCK = 512;
7
+ // the header of an entry, encoded in one block (node-tar cuts a long name to fit it)
8
+ function block(header) {
9
+ const buf = Buffer.alloc(BLOCK);
10
+ header.encode(buf, 0);
11
+ return buf;
12
+ }
13
+ // the bytes of `content` padded to whole blocks
14
+ function padded(content) {
15
+ const rest = content.length % BLOCK;
16
+ return rest === 0 ? content : Buffer.concat([content, Buffer.alloc(BLOCK - rest)]);
17
+ }
18
+ /**
19
+ * The archive of `files`: each at its path, with its mode, mtime and content. An empty list is
20
+ * an empty archive, the two blocks that end one.
21
+ */
22
+ function tarFiles(files) {
23
+ const blocks = [];
24
+ for (const file of files) {
25
+ const mtime = file.mtime ?? new Date();
26
+ const header = new tar_1.Header({
27
+ path: file.path,
28
+ mode: file.mode,
29
+ size: file.content.length,
30
+ type: 'File',
31
+ mtime,
32
+ });
33
+ // encoding sets `needPax` when the path does not fit a ustar header
34
+ const head = block(header);
35
+ if (header.needPax) {
36
+ const body = Buffer.from(new tar_1.Pax({ path: file.path }, false).encodeBody());
37
+ const extended = new tar_1.Header({
38
+ path: `PaxHeader/${path_1.posix.basename(file.path)}`.slice(0, 100),
39
+ mode: 0o644,
40
+ size: body.length,
41
+ type: 'ExtendedHeader',
42
+ mtime,
43
+ });
44
+ blocks.push(block(extended), padded(body));
45
+ }
46
+ blocks.push(head, padded(file.content));
47
+ }
48
+ blocks.push(Buffer.alloc(BLOCK * 2));
49
+ return Buffer.concat(blocks);
50
+ }
51
+ exports.tarFiles = tarFiles;
52
+ //# sourceMappingURL=tar-files.js.map
package/dist/utils/tar.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onlyBelow = exports.extractOutput = exports.packArchive = void 0;
3
+ exports.onlyBelow = exports.extractOutput = exports.measureArchive = exports.packArchive = void 0;
4
+ const fs_1 = require("fs");
4
5
  const tar_1 = require("tar");
5
6
  const path_1 = require("path");
6
7
  function packArchive(options, files) {
@@ -34,6 +35,41 @@ const NOT_PACKED = '\0';
34
35
  function isExact(key) {
35
36
  return key.split(':').every((part) => Number.isSafeInteger(Number(part)));
36
37
  }
38
+ // The entries of an archive and the bytes of their content, unpacked, measured before anything
39
+ // is extracted from it. Reading stops at the first entry that takes it past `limit`, so what
40
+ // is returned is then more than the limit, and the rest of the archive is not read.
41
+ function measureArchive(file, limit) {
42
+ return new Promise((resolve, reject) => {
43
+ const measured = { entries: 0, bytes: 0 };
44
+ let done = false;
45
+ const source = (0, fs_1.createReadStream)(file);
46
+ const parser = new tar_1.Parser({
47
+ onReadEntry: (entry) => {
48
+ if (done) {
49
+ entry.resume();
50
+ return;
51
+ }
52
+ measured.entries++;
53
+ measured.bytes += entry.size ?? 0;
54
+ entry.resume();
55
+ if (measured.entries > limit.entries || measured.bytes > limit.bytes) {
56
+ done = true;
57
+ source.unpipe(parser);
58
+ source.destroy();
59
+ resolve({ ...measured });
60
+ }
61
+ },
62
+ });
63
+ parser.on('end', () => {
64
+ done = true;
65
+ resolve({ ...measured });
66
+ });
67
+ parser.on('error', reject);
68
+ source.on('error', reject);
69
+ source.pipe(parser);
70
+ });
71
+ }
72
+ exports.measureArchive = measureArchive;
37
73
  // Extracts the archive of one output (a path relative to `cwd`) into `cwd`. An archive
38
74
  // comes from a cache another run, or whoever writes to the cache backend, filled, so only
39
75
  // entries of that output are taken: one beside it (another output, a source of the task, a
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hammerkit",
3
3
  "description": "Containerized build tool with incremental caching that runs the same build file locally, in Docker and on Kubernetes.",
4
- "version": "2.1.0-next.2",
4
+ "version": "2.1.0-next.20",
5
5
  "keywords": [
6
6
  "build",
7
7
  "build-tool",