hammerkit 2.1.0-next.9 → 2.1.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.
- package/build.schema.json +28 -126
- package/dist/cli.js +0 -5
- package/dist/dashboard/assets/graph-canvas-DtJSpova.js +8 -0
- package/dist/dashboard/assets/index-BndChMep.css +2 -0
- package/dist/dashboard/assets/{index-CE5PSB3y.js → index-DRSwIRXd.js} +9 -15
- package/dist/dashboard/index.html +2 -2
- package/dist/docker/item-network.js +5 -6
- package/dist/docker/remove-orphaned-containers.js +4 -5
- package/dist/environment/replace-env-variables.js +5 -8
- package/dist/environment/run-source-envs.js +1 -2
- package/dist/executer/check-readiness.js +4 -8
- package/dist/executer/deadline.js +63 -10
- package/dist/executer/docker-service.js +15 -21
- package/dist/executer/execute-work-task.js +15 -3
- package/dist/harness/sandbox-client.js +1 -0
- package/dist/harness/service-tools.js +25 -1
- package/dist/kubernetes/cluster-state.js +48 -14
- package/dist/kubernetes/ensure-kubernetes-deployment-exists.js +14 -62
- package/dist/kubernetes/ensure-persistent-data.js +14 -3
- package/dist/kubernetes/kept-claims.js +9 -12
- package/dist/kubernetes/resources.js +5 -1
- package/dist/optimizer/work-task-cache-description.js +3 -5
- package/dist/planner/image-build.js +0 -5
- package/dist/planner/service-definition.js +1 -2
- package/dist/planner/utils/append-work-service.js +4 -12
- package/dist/planner/utils/dependency-outputs.js +6 -7
- package/dist/planner/validate.js +0 -41
- package/dist/planner/work-healthcheck.js +2 -23
- package/dist/planner/work-runtime-docker.js +1 -24
- package/dist/planner/work-runtime-kubernetes.js +16 -37
- package/dist/planner/work-secret.js +11 -33
- package/dist/planner/work-service-id.js +6 -30
- package/dist/planner/work-service.js +2 -2
- package/dist/program.js +1 -19
- package/dist/remote/annotations.js +31 -11
- package/dist/remote/collect-bundle.js +3 -2
- package/dist/remote/remote-status.js +1 -1
- package/dist/remote/remote-work-commands.js +53 -12
- package/dist/schema/build-file-base-task-schema.js +1 -16
- package/dist/schema/build-file-image-build-schema.js +8 -5
- package/dist/schema/build-file-service-container-healthcheck.js +7 -25
- package/dist/schema/reference-parser.js +43 -108
- package/dist/schema/work-scope-parser.js +0 -8
- package/dist/secrets/prefetch-secrets.js +1 -20
- package/dist/server/capacity.js +6 -18
- package/dist/server/endpoints.js +52 -32
- package/dist/server/kubernetes-backend.js +28 -114
- package/dist/server/kubernetes-sandbox-storage.js +2 -3
- package/dist/server/overview.js +1 -7
- package/dist/server/plan.js +0 -8
- package/dist/server/public-paths.js +52 -0
- package/dist/server/run-request.js +52 -1
- package/dist/server/run-retry.js +6 -0
- package/dist/server/run-source-environment.js +1 -1
- package/dist/server/runs.js +6 -4
- package/dist/server/sandbox-files-api.js +12 -27
- package/dist/server/sandbox-files.js +2 -3
- package/dist/server/sandbox-pod.js +1 -1
- package/dist/server/sandboxes-api.js +14 -65
- package/dist/server/sandboxes.js +3 -19
- package/dist/server/server-config.js +2 -59
- package/dist/server/server.js +20 -8
- package/dist/server/service-runs.js +41 -8
- package/package.json +1 -1
- package/dist/dashboard/assets/graph-canvas-BFnEN5i0.js +0 -8
- package/dist/dashboard/assets/index-Dt3ITvRO.css +0 -2
- package/dist/executer/docker-healthcheck.js +0 -73
- package/dist/network/healthcheck-request.js +0 -38
- package/dist/server/borrowed-quota.js +0 -216
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensurePersistentData = exports.packSource = exports.clearStateFiles = exports.ENSURE_OUTPUT_FILES = exports.restoreLiveFiles = exports.syncLiveFiles = exports.SYNC_FILES = exports.getStateDirsInUse = exports.REMOVE_OTHER_STATES = exports.execInPod = exports.clearClaim = exports.getPodForPersistence = exports.applyWithinQuota = exports.QUOTA_TIMEOUT = exports.TRANSFER_POD_RESOURCES = void 0;
|
|
3
|
+
exports.ensurePersistentData = exports.packSource = exports.clearStateFiles = exports.ENSURE_OUTPUT_FILES = exports.restoreLiveFiles = exports.syncLiveFiles = exports.SYNC_FILES = exports.getStateDirsInUse = exports.REMOVE_OTHER_STATES = exports.execInPod = exports.clearClaim = exports.getPodForPersistence = exports.applyWithinQuota = exports.QUOTA_TIMEOUT = exports.getTransferPodScript = exports.TRANSFER_POD_RESOURCES = void 0;
|
|
4
4
|
const quota_wait_1 = require("./quota-wait");
|
|
5
5
|
Object.defineProperty(exports, "QUOTA_TIMEOUT", { enumerable: true, get: function () { return quota_wait_1.QUOTA_TIMEOUT; } });
|
|
6
6
|
const volumes_1 = require("./volumes");
|
|
@@ -54,6 +54,15 @@ exports.TRANSFER_POD_RESOURCES = {
|
|
|
54
54
|
requests: { cpu: '50m', memory: '64Mi' },
|
|
55
55
|
limits: { memory: '512Mi' },
|
|
56
56
|
};
|
|
57
|
+
// What the transfer pod runs while files are copied through exec: it waits, and ends at once
|
|
58
|
+
// and with 0 when the pod is deleted. A shell as process 1 ignores SIGTERM unless it traps it,
|
|
59
|
+
// and was killed at the end of the grace period of its deletion, 30 seconds later and with
|
|
60
|
+
// 137, which the log of a run that failed meanwhile showed as a failed pod.
|
|
61
|
+
// `busybox` is the one of the pod.
|
|
62
|
+
function getTransferPodScript(busybox) {
|
|
63
|
+
return `trap 'kill $! 2>/dev/null; exit 0' TERM; ${busybox} sleep 2147483647 & wait`;
|
|
64
|
+
}
|
|
65
|
+
exports.getTransferPodScript = getTransferPodScript;
|
|
57
66
|
// A Job waits for room under a full quota, a pod is refused: so a transfer pod is
|
|
58
67
|
// created again until the pods of the tasks it runs beside are done and make room
|
|
59
68
|
async function applyWithinQuota(instance, podSpec, service, timeout = quota_wait_1.QUOTA_TIMEOUT, pollInterval = 2000,
|
|
@@ -139,6 +148,8 @@ signal, fn) {
|
|
|
139
148
|
},
|
|
140
149
|
annotations: {
|
|
141
150
|
'hammerkit.dev/version': (0, version_1.getVersion)(),
|
|
151
|
+
[resources_1.HELPER_ANNOTATION]: type === 'write' ? 'upload' : 'download',
|
|
152
|
+
[resources_1.ITEM_ANNOTATION]: service.name,
|
|
142
153
|
},
|
|
143
154
|
},
|
|
144
155
|
spec: {
|
|
@@ -156,8 +167,8 @@ signal, fn) {
|
|
|
156
167
|
{
|
|
157
168
|
name: 'volume',
|
|
158
169
|
image: transfer_tools_1.HELPER_TOOLS_IMAGE,
|
|
159
|
-
|
|
160
|
-
|
|
170
|
+
// no tty: it kept an interactive shell waiting, which ignores SIGTERM
|
|
171
|
+
command: (0, transfer_tools_1.inTransferPod)(['sh', '-c', getTransferPodScript(transfer_tools_1.TRANSFER_BUSYBOX)]),
|
|
161
172
|
env: transfer_tools_1.TRANSFER_TOOLS_ENV,
|
|
162
173
|
volumeMounts: [...mounts, transfer_tools_1.TRANSFER_TOOLS_MOUNT],
|
|
163
174
|
resources: exports.TRANSFER_POD_RESOURCES,
|
|
@@ -19,16 +19,13 @@ exports.STATE_ANNOTATION = 'hammerkit.dev/state';
|
|
|
19
19
|
// when it goes, set by the end of the run that mounted it last
|
|
20
20
|
exports.EXPIRES_ANNOTATION = 'hammerkit.dev/expires';
|
|
21
21
|
// The claim of a work item: a task's on a server that keeps them carries the scope, so a
|
|
22
|
-
// run of another source never mounts it, and the
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// names have a claim each. Any other claim on a server is the run's own, as the runs of a
|
|
26
|
-
// caller share their namespace. 63 characters at most, a pod's volume name.
|
|
22
|
+
// run of another source never mounts it, and the runs of one scope go one at a time
|
|
23
|
+
// (KubernetesExecutor.exclusive). Any other claim on a server is the run's own, as the
|
|
24
|
+
// runs of a caller share their namespace. 63 characters at most, a pod's volume name.
|
|
27
25
|
function getClaimName(work, kubernetes) {
|
|
28
26
|
const scope = kubernetes.server?.volumeScope;
|
|
29
27
|
if (scope && isTask(work)) {
|
|
30
|
-
|
|
31
|
-
return `hammerkit-${work.id()}-${owner}`;
|
|
28
|
+
return `hammerkit-${work.id()}-${(0, crypto_1.createHash)('sha256').update(scope).digest('hex').slice(0, 12)}`;
|
|
32
29
|
}
|
|
33
30
|
return 'hammerkit-' + (0, resources_1.getItemKey)(work, kubernetes);
|
|
34
31
|
}
|
|
@@ -204,17 +201,17 @@ async function sweepKeptClaims(instance, namespace, options) {
|
|
|
204
201
|
exports.sweepKeptClaims = sweepKeptClaims;
|
|
205
202
|
// When a run needs room under the quota of its namespace: the kept claims it does not use
|
|
206
203
|
// go, those of the other sources and those of its own a task of this run did not take (one
|
|
207
|
-
// renamed or changed since
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
// stopped, which the next sweep removes). The names of those removed.
|
|
204
|
+
// renamed or changed since). Of another scope, only one its last run released, which has an
|
|
205
|
+
// expiry: one without is mounted by a run of the caller that executes now (or was left by
|
|
206
|
+
// a server that stopped, which the next sweep removes). The names of those removed.
|
|
211
207
|
async function evictKeptClaims(instance, kubernetes, timeout) {
|
|
212
208
|
const server = kubernetes.server;
|
|
213
209
|
if (!server?.volumeScope) {
|
|
214
210
|
return [];
|
|
215
211
|
}
|
|
216
212
|
const unused = await listKeptClaims(instance, kubernetes.namespace, `${exports.VOLUME_SCOPE_LABEL},${exports.KEPT_BY_LABEL}!=${(0, job_placement_1.getRunLabelValue)(server.run)}`);
|
|
217
|
-
const released = unused.filter((claim) =>
|
|
213
|
+
const released = unused.filter((claim) => claim.metadata?.labels?.[exports.VOLUME_SCOPE_LABEL] === server.volumeScope ||
|
|
214
|
+
!!claim.metadata?.annotations?.[exports.EXPIRES_ANNOTATION]);
|
|
218
215
|
return removeClaims(instance, kubernetes.namespace, released, timeout);
|
|
219
216
|
}
|
|
220
217
|
exports.evictKeptClaims = evictKeptClaims;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeInvalidCharacters = exports.getResourceName = exports.getItemSelector = exports.getItemLabels = exports.getItemKey = exports.ID_LABEL = void 0;
|
|
3
|
+
exports.removeInvalidCharacters = exports.getResourceName = exports.getItemSelector = exports.getItemLabels = exports.getItemKey = exports.ITEM_ANNOTATION = exports.HELPER_ANNOTATION = exports.ID_LABEL = void 0;
|
|
4
4
|
const job_placement_1 = require("./job-placement");
|
|
5
5
|
// An object name is a DNS label: lowercase letters, digits and `-`, at most 63
|
|
6
6
|
// characters, starting and ending with a letter or digit. The id makes a name
|
|
7
7
|
// unique; the item's name is there for people and is cut to fit.
|
|
8
8
|
const MAX_NAME = 63;
|
|
9
9
|
exports.ID_LABEL = 'hammerkit.dev/id';
|
|
10
|
+
// On a pod that copies files of an item into or out of its claim: `upload` or `download`, and
|
|
11
|
+
// the item's name, so what the cluster says of the pod is not taken for the item
|
|
12
|
+
exports.HELPER_ANNOTATION = 'hammerkit.dev/helper';
|
|
13
|
+
exports.ITEM_ANNOTATION = 'hammerkit.dev/item';
|
|
10
14
|
// What tells the objects of an item apart in its namespace: its id, and on a server the
|
|
11
15
|
// run's label too. The runs of a caller execute side by side in their namespace, and two
|
|
12
16
|
// of them often run the same task (the same command on two sandboxes of a repository),
|
|
@@ -10,7 +10,6 @@ const claim_layout_1 = require("../kubernetes/claim-layout");
|
|
|
10
10
|
const work_service_1 = require("../planner/work-service");
|
|
11
11
|
const work_service_id_1 = require("../planner/work-service-id");
|
|
12
12
|
const work_cache_id_1 = require("../planner/work-cache-id");
|
|
13
|
-
const work_healthcheck_1 = require("../planner/work-healthcheck");
|
|
14
13
|
// Every path is made project-relative (portablePath) so the description, and the
|
|
15
14
|
// task id hashed from it, is identical wherever the project is checked out.
|
|
16
15
|
//
|
|
@@ -88,15 +87,14 @@ function isInitOf(item, service) {
|
|
|
88
87
|
// Everything that makes a service what a task needing it talks to: its definition, the ids of
|
|
89
88
|
// the tasks it depends on and of its init task, and the services it needs in turn. The source
|
|
90
89
|
// of those tasks and of the service is in the state key (computeStateKey), like a dependency's.
|
|
91
|
-
// Not the service id, which leaves out what a service runs
|
|
92
|
-
// a renamed service is the same (getUnnamedWorkServiceId).
|
|
90
|
+
// Not the service id, which leaves out what a service runs (getWorkServiceId).
|
|
93
91
|
function getWorkServiceCacheIdentity(item, visiting = new Set()) {
|
|
94
92
|
const service = item.data;
|
|
95
93
|
const definition = (0, work_service_1.isContainerWorkService)(service)
|
|
96
94
|
? {
|
|
97
95
|
cmd: service.cmd?.cmd ?? null,
|
|
98
96
|
envs: (0, replace_env_variables_1.getEnvironmentVariables)(service.envs),
|
|
99
|
-
healthcheck: service.healthcheck
|
|
97
|
+
healthcheck: service.healthcheck?.cmd.cmd ?? null,
|
|
100
98
|
secrets: service.secrets
|
|
101
99
|
.filter((secret) => secret.cache)
|
|
102
100
|
.map((secret) => `${(0, work_secret_1.getPortableSecretName)(service.projectRoot, secret)}=${secret.digest()}`)
|
|
@@ -111,7 +109,7 @@ function getWorkServiceCacheIdentity(item, visiting = new Set()) {
|
|
|
111
109
|
: { namespace: service.namespace };
|
|
112
110
|
return (0, crypto_1.createHash)('sha256')
|
|
113
111
|
.update(JSON.stringify({
|
|
114
|
-
id: (0, work_service_id_1.
|
|
112
|
+
id: (0, work_service_id_1.getWorkServiceId)(service),
|
|
115
113
|
...definition,
|
|
116
114
|
ports: service.ports.map((port) => `${port.hostPort ?? ''}:${port.containerPort}`).sort(),
|
|
117
115
|
deps: item.deps.map((dep) => dep.id()).sort(),
|
|
@@ -25,11 +25,6 @@ const METADATA_FILE = '/tmp/hammerkit-build.json';
|
|
|
25
25
|
const IMAGE = /^[a-z0-9][a-z0-9._/:@-]*$/i;
|
|
26
26
|
// The build of a task, with the values of its envs in place
|
|
27
27
|
function parseWorkImageBuild(cwd, build, envs, taskName) {
|
|
28
|
-
// checked here, not in the schema: a base of `extend` may set push for tasks that set their tags
|
|
29
|
-
const needsTags = build.push ? 'push' : build.digest !== undefined ? 'digest' : null;
|
|
30
|
-
if (needsTags && build.tags === undefined) {
|
|
31
|
-
throw new Error(`task ${taskName}: build ${needsTags} needs tags, the names of the image`);
|
|
32
|
-
}
|
|
33
28
|
const context = (0, path_1.join)(cwd, (0, template_value_1.templateValue)(build.context ?? '.', envs));
|
|
34
29
|
const dockerfile = build.dockerfile ? (0, path_1.join)(cwd, (0, template_value_1.templateValue)(build.dockerfile, envs)) : (0, path_1.join)(context, 'Dockerfile');
|
|
35
30
|
const tags = (build.tags === undefined ? [] : Array.isArray(build.tags) ? build.tags : [build.tags]).map((tag) => checkImage((0, template_value_1.templateValue)(tag, envs), 'tag', taskName));
|
|
@@ -7,7 +7,6 @@ const work_service_1 = require("./work-service");
|
|
|
7
7
|
const work_network_1 = require("./work-network");
|
|
8
8
|
const work_cache_id_1 = require("./work-cache-id");
|
|
9
9
|
const portable_path_1 = require("./utils/portable-path");
|
|
10
|
-
const work_healthcheck_1 = require("./work-healthcheck");
|
|
11
10
|
// Everything a running container of the service was created from, plus the
|
|
12
11
|
// definitions of the services it needs: a dependent links to the container it
|
|
13
12
|
// started with, so a recreated need means a recreated dependent too. Stored as
|
|
@@ -33,7 +32,7 @@ function getServiceDefinitionHash(item) {
|
|
|
33
32
|
// the volume of a dep's output is named by where it is, which its path says already
|
|
34
33
|
volumes: service.volumes.map((v) => `${v.inherited ? '' : v.name}:${portable(v.containerPath)}:${v.readOnly ? 'ro' : 'rw'}`),
|
|
35
34
|
src: service.src.map((s) => portable(s.absolutePath)),
|
|
36
|
-
healthcheck: service.healthcheck
|
|
35
|
+
healthcheck: service.healthcheck?.cmd.cmd ?? null,
|
|
37
36
|
// where secrets go, never their values: a rotated value needs a `down`
|
|
38
37
|
secrets: service.secrets.map((s) => s.source.type === 'provider'
|
|
39
38
|
? `provider:${(0, work_secret_1.getSecretName)(s)}:${(0, work_secret_1.describeSecretSource)(s)}`
|
|
@@ -98,7 +98,10 @@ function parseService(workTree, service, environment, context) {
|
|
|
98
98
|
type: 'container-service',
|
|
99
99
|
continuous: service.schema.continuous ?? false,
|
|
100
100
|
healthcheck: service.schema.healthcheck
|
|
101
|
-
?
|
|
101
|
+
? {
|
|
102
|
+
cmd: (0, parse_work_command_1.parseWorkCommand)(service.cwd, service.schema.healthcheck.cmd, envs),
|
|
103
|
+
timeout: getHealthcheckTimeout(service.schema.healthcheck.timeout, environment),
|
|
104
|
+
}
|
|
102
105
|
: null,
|
|
103
106
|
envs: (0, replace_env_variables_1.buildEnvironmentVariables)(service.envs, environment, context),
|
|
104
107
|
image: (0, template_value_1.templateValue)(service.schema.image, envs),
|
|
@@ -198,17 +201,6 @@ function getInitTimeout(timeout, environment) {
|
|
|
198
201
|
return (0, units_1.parseDuration)(exports.DEFAULT_INIT_TIMEOUT);
|
|
199
202
|
}
|
|
200
203
|
exports.getInitTimeout = getInitTimeout;
|
|
201
|
-
function parseWorkHealthcheck(cwd, healthcheck, envs, environment) {
|
|
202
|
-
const timeout = getHealthcheckTimeout(healthcheck.timeout, environment);
|
|
203
|
-
if ('cmd' in healthcheck) {
|
|
204
|
-
return { cmd: (0, parse_work_command_1.parseWorkCommand)(cwd, healthcheck.cmd, envs), timeout };
|
|
205
|
-
}
|
|
206
|
-
if ('http' in healthcheck) {
|
|
207
|
-
const { port, path, scheme, status } = healthcheck.http;
|
|
208
|
-
return { http: { port, path: path ?? '/', scheme: scheme ?? 'http', status: status ?? null }, timeout };
|
|
209
|
-
}
|
|
210
|
-
return { tcp: { port: healthcheck.tcp.port }, timeout };
|
|
211
|
-
}
|
|
212
204
|
exports.DEFAULT_HEALTHCHECK_TIMEOUT = '20s';
|
|
213
205
|
// A service's own `healthcheck.timeout`, else HAMMERKIT_HEALTHCHECK_TIMEOUT,
|
|
214
206
|
// else 20s: a check that never passes fails the run instead of hanging it.
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDependencyOutput = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
// Whether a path is a
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// the
|
|
9
|
-
//
|
|
10
|
-
// writes reads it so, and a deploy that lists the digest file of its image in its src.
|
|
5
|
+
// Whether a path is, or is inside, a folder a dependency of the task generates. The task sees
|
|
6
|
+
// what the dependency made there: a src at such a path stays a src of the task (its id and its
|
|
7
|
+
// cache key are as they were), but isn't bound or mounted over the output, as docker would bind
|
|
8
|
+
// the host's folder (empty where the dependency ran in a container) and a pod would mount the
|
|
9
|
+
// same path twice. A `build` whose context a dependency writes reads it so.
|
|
11
10
|
function isDependencyOutput(task, path) {
|
|
12
|
-
return task.generates.some((generate) => generate.inherited && (generate.path === path ||
|
|
11
|
+
return task.generates.some((generate) => generate.inherited && !generate.isFile && (generate.path === path || isInside(generate.path, path)));
|
|
13
12
|
}
|
|
14
13
|
exports.isDependencyOutput = isDependencyOutput;
|
|
15
14
|
function isInside(folder, path) {
|
package/dist/planner/validate.js
CHANGED
|
@@ -5,16 +5,6 @@ const read_build_file_1 = require("../parser/read-build-file");
|
|
|
5
5
|
const plan_work_tasks_1 = require("./utils/plan-work-tasks");
|
|
6
6
|
const unreferenced_build_file_envs_1 = require("./unreferenced-build-file-envs");
|
|
7
7
|
const normalize_path_1 = require("./utils/normalize-path");
|
|
8
|
-
const dependency_outputs_1 = require("./utils/dependency-outputs");
|
|
9
|
-
const run_source_envs_1 = require("../environment/run-source-envs");
|
|
10
|
-
const work_secret_1 = require("./work-secret");
|
|
11
|
-
// A provider or account is declared by the machine that runs a task, in its host config, not
|
|
12
|
-
// by the build file: the build file is valid, only running the task here fails.
|
|
13
|
-
function* warnUnreadableSecrets(item) {
|
|
14
|
-
for (const reason of (0, work_secret_1.getUnreadableSecrets)(item.secrets)) {
|
|
15
|
-
yield { type: 'warn', message: `${reason}, running it here fails`, item };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
8
|
async function* validate(workTree, context) {
|
|
19
9
|
const cycleItems = [];
|
|
20
10
|
for (const item of (0, plan_work_tasks_1.iterateWorkServices)(workTree)) {
|
|
@@ -23,8 +13,6 @@ async function* validate(workTree, context) {
|
|
|
23
13
|
yield { type: 'warn', message: `missing description`, item: service };
|
|
24
14
|
}
|
|
25
15
|
if (service.type === 'container-service') {
|
|
26
|
-
yield* warnUnreadableSecrets(service);
|
|
27
|
-
yield* warnUnsetEnvs(service.envs, service);
|
|
28
16
|
if (!service.healthcheck) {
|
|
29
17
|
yield { type: 'warn', message: 'missing healthcheck', item: service };
|
|
30
18
|
}
|
|
@@ -64,8 +52,6 @@ async function* validate(workTree, context) {
|
|
|
64
52
|
if (!task.description) {
|
|
65
53
|
yield { type: 'warn', message: `missing description`, item: task };
|
|
66
54
|
}
|
|
67
|
-
yield* warnUnsetEnvs(task.envs, task);
|
|
68
|
-
yield* warnUnreadableSecrets(task);
|
|
69
55
|
if (task.type === 'local-task' && task.resources) {
|
|
70
56
|
yield { type: 'warn', message: 'resources are not enforced for a local task', item: task };
|
|
71
57
|
}
|
|
@@ -88,10 +74,6 @@ async function* validate(workTree, context) {
|
|
|
88
74
|
}
|
|
89
75
|
}
|
|
90
76
|
for (const src of task.src) {
|
|
91
|
-
// a dependency writes it when it runs: the digest of an image a deploy lists in its src
|
|
92
|
-
if ((0, dependency_outputs_1.isDependencyOutput)(task, src.absolutePath)) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
77
|
if (!(await context.file.exists(src.absolutePath))) {
|
|
96
78
|
yield {
|
|
97
79
|
type: 'warn',
|
|
@@ -121,29 +103,6 @@ async function* validate(workTree, context) {
|
|
|
121
103
|
}
|
|
122
104
|
}
|
|
123
105
|
exports.validate = validate;
|
|
124
|
-
// An env that reads a variable set nowhere, such as an input of an included file run on its
|
|
125
|
-
// own: the task fails when it starts, and until then `$NAME` stays in what it templates. Each
|
|
126
|
-
// variable a value reads counts, `${A}-${B}` both. The variables of what a run is from
|
|
127
|
-
// (`$HAMMERKIT_RUN_REF`) are not of them: a server sets them when it runs the task
|
|
128
|
-
// (RUN_SOURCE_ENVS).
|
|
129
|
-
function* warnUnsetEnvs(envs, item) {
|
|
130
|
-
for (const replacement of envs.replacements) {
|
|
131
|
-
if (replacement.available) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
for (const name of replacement.missing ?? [replacement.name]) {
|
|
135
|
-
if ((0, run_source_envs_1.isRunSourceEnv)(name)) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
yield {
|
|
139
|
-
type: 'warn',
|
|
140
|
-
message: `env ${replacement.key} reads $${name}, which neither the environment nor a .env file sets: ` +
|
|
141
|
-
`it can't start, and $${replacement.key} stays as it is written in its build file`,
|
|
142
|
-
item,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
106
|
function hasMixedCycle(item, currentPath) {
|
|
148
107
|
if (currentPath.indexOf(item) >= 0) {
|
|
149
108
|
return [...currentPath, item];
|
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHealthcheckTimeoutMessage =
|
|
3
|
+
exports.getHealthcheckTimeoutMessage = void 0;
|
|
4
4
|
const units_1 = require("../utils/units");
|
|
5
|
-
// What the check is, in the definition of the service and its cache identity: a command as
|
|
6
|
-
// it is written, so those of a service with one stay what they were. Not its timeout.
|
|
7
|
-
function getHealthcheckDefinition(healthcheck) {
|
|
8
|
-
if ('cmd' in healthcheck) {
|
|
9
|
-
return healthcheck.cmd.cmd;
|
|
10
|
-
}
|
|
11
|
-
return 'http' in healthcheck ? { http: healthcheck.http } : { tcp: healthcheck.tcp };
|
|
12
|
-
}
|
|
13
|
-
exports.getHealthcheckDefinition = getHealthcheckDefinition;
|
|
14
|
-
// what the check is, for a message
|
|
15
|
-
function describeHealthcheck(healthcheck) {
|
|
16
|
-
if ('cmd' in healthcheck) {
|
|
17
|
-
return healthcheck.cmd.cmd;
|
|
18
|
-
}
|
|
19
|
-
if ('http' in healthcheck) {
|
|
20
|
-
const { scheme, port, path, status } = healthcheck.http;
|
|
21
|
-
return `GET ${scheme}://:${port}${path}${status ? ` (${status.join(', ')})` : ''}`;
|
|
22
|
-
}
|
|
23
|
-
return `tcp :${healthcheck.tcp.port}`;
|
|
24
|
-
}
|
|
25
|
-
exports.describeHealthcheck = describeHealthcheck;
|
|
26
5
|
function getHealthcheckTimeoutMessage(serviceName, healthcheck) {
|
|
27
|
-
return (`service ${serviceName} did not pass its healthcheck "${
|
|
6
|
+
return (`service ${serviceName} did not pass its healthcheck "${healthcheck.cmd.cmd}" within ` +
|
|
28
7
|
`${(0, units_1.formatDuration)(healthcheck.timeout)} of starting (see its log above; raise healthcheck.timeout ` +
|
|
29
8
|
`or HAMMERKIT_HEALTHCHECK_TIMEOUT if it is just slow)`);
|
|
30
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.dockerServiceRuntime = exports.getCacheHelperOptions = exports.dockerTaskRuntime = void 0;
|
|
4
4
|
const run_labels_1 = require("../docker/run-labels");
|
|
5
5
|
const execute_docker_1 = require("../executer/execute-docker");
|
|
6
6
|
const remove_container_1 = require("../docker/remove-container");
|
|
@@ -14,7 +14,6 @@ const path_1 = require("path");
|
|
|
14
14
|
const tar_1 = require("../utils/tar");
|
|
15
15
|
const plan_work_volume_1 = require("./utils/plan-work-volume");
|
|
16
16
|
const work_instance_id_1 = require("./work-instance-id");
|
|
17
|
-
const work_service_id_1 = require("./work-service-id");
|
|
18
17
|
const stream_1 = require("stream");
|
|
19
18
|
const service_definition_1 = require("./service-definition");
|
|
20
19
|
const image_build_1 = require("./image-build");
|
|
@@ -205,7 +204,6 @@ function dockerServiceRuntime(service, workEnvironment) {
|
|
|
205
204
|
const docker = (0, execute_docker_1.getContainerCli)(workEnvironment);
|
|
206
205
|
return {
|
|
207
206
|
async initialize(state) {
|
|
208
|
-
await removeLegacyService(docker, service);
|
|
209
207
|
const currentServices = await docker.listContainers({
|
|
210
208
|
filters: {
|
|
211
209
|
label: [`hammerkit-id=${(0, work_instance_id_1.getWorkInstanceId)(service)}`],
|
|
@@ -294,27 +292,6 @@ function dockerServiceRuntime(service, workEnvironment) {
|
|
|
294
292
|
};
|
|
295
293
|
}
|
|
296
294
|
exports.dockerServiceRuntime = dockerServiceRuntime;
|
|
297
|
-
// A service an earlier version started, labeled with the id it had then: it goes with its
|
|
298
|
-
// network and secrets, and is recreated under its own id (getLegacyServiceItem).
|
|
299
|
-
async function removeLegacyService(docker, service) {
|
|
300
|
-
const legacy = (0, work_service_id_1.getLegacyServiceItem)(service);
|
|
301
|
-
const containers = await docker.listContainers({
|
|
302
|
-
all: true,
|
|
303
|
-
filters: {
|
|
304
|
-
label: [`hammerkit-id=${(0, work_instance_id_1.getWorkInstanceId)(legacy)}`, 'hammerkit-type=service'],
|
|
305
|
-
},
|
|
306
|
-
});
|
|
307
|
-
if (containers.length === 0) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
service.status.write('info', `${service.name} was started by an earlier version of hammerkit, recreating it`);
|
|
311
|
-
for (const container of containers) {
|
|
312
|
-
await (0, remove_container_1.removeContainer)(docker.getContainer(container.Id));
|
|
313
|
-
}
|
|
314
|
-
await (0, item_network_1.removeItemNetworks)(docker, legacy);
|
|
315
|
-
await (0, container_secrets_1.removeContainerSecrets)((0, work_instance_id_1.getWorkInstanceId)(legacy));
|
|
316
|
-
}
|
|
317
|
-
exports.removeLegacyService = removeLegacyService;
|
|
318
295
|
async function archiveContainer(docker, environment, item, path) {
|
|
319
296
|
await (0, execution_steps_1.refuseHostLinks)(item, environment);
|
|
320
297
|
await (0, using_container_1.usingContainer)(docker, item, getCacheHelperOptions(item, environment), async (container) => {
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.kubernetesForwardRuntime = exports.isRolledOut = exports.kubernetesServiceRuntime = exports.
|
|
6
|
+
exports.kubernetesForwardRuntime = exports.isRolledOut = exports.kubernetesServiceRuntime = exports.kubernetesTaskRuntime = exports.getTaskJobContainers = exports.describeFailedJob = exports.recordJobExecution = void 0;
|
|
7
7
|
const abort_1 = require("../executer/abort");
|
|
8
8
|
const kubernetes_service_1 = require("../executer/kubernetes-service");
|
|
9
9
|
const kubernetes_instance_1 = require("../kubernetes/kubernetes-instance");
|
|
@@ -14,7 +14,6 @@ const ensure_kubernetes_deployment_exists_1 = require("../kubernetes/ensure-kube
|
|
|
14
14
|
const follow_pod_logs_1 = require("../kubernetes/follow-pod-logs");
|
|
15
15
|
const work_item_executions_1 = require("./work-item-executions");
|
|
16
16
|
const service_definition_1 = require("./service-definition");
|
|
17
|
-
const work_service_id_1 = require("./work-service-id");
|
|
18
17
|
const ensure_namespace_1 = require("../kubernetes/ensure-namespace");
|
|
19
18
|
const ensure_persistent_data_1 = require("../kubernetes/ensure-persistent-data");
|
|
20
19
|
const network_gate_1 = require("../kubernetes/network-gate");
|
|
@@ -531,35 +530,6 @@ function kubernetesTaskRuntime(task, kubernetes) {
|
|
|
531
530
|
};
|
|
532
531
|
}
|
|
533
532
|
exports.kubernetesTaskRuntime = kubernetesTaskRuntime;
|
|
534
|
-
async function stopKubernetesService(instance, kubernetes, service) {
|
|
535
|
-
const deployments = await instance.appsApi.listNamespacedDeployment({
|
|
536
|
-
namespace: kubernetes.namespace,
|
|
537
|
-
labelSelector: (0, resources_1.getItemSelector)(service, kubernetes),
|
|
538
|
-
});
|
|
539
|
-
for (const deployment of deployments.items) {
|
|
540
|
-
if (deployment.metadata?.name) {
|
|
541
|
-
await instance.appsApi.deleteNamespacedDeployment({
|
|
542
|
-
name: deployment.metadata.name,
|
|
543
|
-
namespace: kubernetes.namespace,
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
await (0, secrets_1.removeKubernetesSecret)(instance, kubernetes, service);
|
|
548
|
-
// the limits go last, once the service's pods ended
|
|
549
|
-
await (0, network_policy_1.removeAllKubernetesItemNetworks)(instance, kubernetes, service);
|
|
550
|
-
}
|
|
551
|
-
async function removeLegacyKubernetesService(instance, kubernetes, service) {
|
|
552
|
-
const legacy = (0, work_service_id_1.getLegacyServiceItem)(service);
|
|
553
|
-
const deployments = await instance.appsApi.listNamespacedDeployment({
|
|
554
|
-
namespace: kubernetes.namespace,
|
|
555
|
-
labelSelector: (0, resources_1.getItemSelector)(legacy, kubernetes),
|
|
556
|
-
});
|
|
557
|
-
if (deployments.items.length > 0) {
|
|
558
|
-
service.status.write('info', `${service.name} was started by an earlier version of hammerkit, recreating it`);
|
|
559
|
-
await stopKubernetesService(instance, kubernetes, legacy);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
exports.removeLegacyKubernetesService = removeLegacyKubernetesService;
|
|
563
533
|
function kubernetesServiceRuntime(service, kubernetes) {
|
|
564
534
|
const instance = (0, kubernetes_instance_1.createKubernetesInstances)(kubernetes);
|
|
565
535
|
return {
|
|
@@ -571,11 +541,6 @@ function kubernetesServiceRuntime(service, kubernetes) {
|
|
|
571
541
|
// a service run starts every service: one that did not change stays as it is (execute)
|
|
572
542
|
return;
|
|
573
543
|
}
|
|
574
|
-
// one an earlier version started, under the id it had then (getLegacyServiceItem); on a
|
|
575
|
-
// server a run finds only objects of its own
|
|
576
|
-
if (!kubernetes.server) {
|
|
577
|
-
await removeLegacyKubernetesService(instance, kubernetes, service);
|
|
578
|
-
}
|
|
579
544
|
const deployments = await instance.appsApi.listNamespacedDeployment({
|
|
580
545
|
namespace: kubernetes.namespace,
|
|
581
546
|
labelSelector: (0, resources_1.getItemSelector)(service, kubernetes),
|
|
@@ -603,7 +568,21 @@ function kubernetesServiceRuntime(service, kubernetes) {
|
|
|
603
568
|
await (0, store_kubernetes_data_1.storeKubernetesData)(service, kubernetes, instance, environment, path);
|
|
604
569
|
},
|
|
605
570
|
async stop() {
|
|
606
|
-
await
|
|
571
|
+
const deployments = await instance.appsApi.listNamespacedDeployment({
|
|
572
|
+
namespace: kubernetes.namespace,
|
|
573
|
+
labelSelector: (0, resources_1.getItemSelector)(service, kubernetes),
|
|
574
|
+
});
|
|
575
|
+
for (const deployment of deployments.items) {
|
|
576
|
+
if (deployment.metadata?.name) {
|
|
577
|
+
await instance.appsApi.deleteNamespacedDeployment({
|
|
578
|
+
name: deployment.metadata.name,
|
|
579
|
+
namespace: kubernetes.namespace,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
await (0, secrets_1.removeKubernetesSecret)(instance, kubernetes, service);
|
|
584
|
+
// the limits go last, once the service's pods ended
|
|
585
|
+
await (0, network_policy_1.removeAllKubernetesItemNetworks)(instance, kubernetes, service);
|
|
607
586
|
},
|
|
608
587
|
async execute(environment, options) {
|
|
609
588
|
const name = (0, resources_1.getResourceName)(service, kubernetes);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSecretDigest = exports.resolveSecretValue = exports.parseWorkSecrets = exports.getPortableSecretName = exports.getSecretName = exports.
|
|
3
|
+
exports.getSecretDigest = exports.resolveSecretValue = exports.parseWorkSecrets = exports.getPortableSecretName = exports.getSecretName = exports.describeSecretSource = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const os_1 = require("os");
|
|
6
6
|
const fs_1 = require("fs");
|
|
@@ -17,17 +17,9 @@ function describeSecretSource(secret) {
|
|
|
17
17
|
if (source.type === 'provider') {
|
|
18
18
|
return `${source.provider}:${source.ref} as ${source.account}`;
|
|
19
19
|
}
|
|
20
|
-
if (source.type === 'unavailable') {
|
|
21
|
-
return source.from;
|
|
22
|
-
}
|
|
23
20
|
return source.type === 'env' ? `env:${source.name}` : `file:${source.path}`;
|
|
24
21
|
}
|
|
25
22
|
exports.describeSecretSource = describeSecretSource;
|
|
26
|
-
// What a task or service reads that this machine can't, one line each, for `ls` and `validate`
|
|
27
|
-
function getUnreadableSecrets(secrets) {
|
|
28
|
-
return secrets.flatMap((secret) => (secret.source.type === 'unavailable' ? [secret.source.reason] : []));
|
|
29
|
-
}
|
|
30
|
-
exports.getUnreadableSecrets = getUnreadableSecrets;
|
|
31
23
|
function getSecretName(secret) {
|
|
32
24
|
return secret.target.type === 'env' ? secret.target.name : secret.target.path;
|
|
33
25
|
}
|
|
@@ -69,37 +61,28 @@ function parseSecretSource(secret, ref, cwd, envs, catalog, taskAccount, owner,
|
|
|
69
61
|
return { type: 'file', path: (0, normalize_path_1.normalizePath)(cwd, (0, os_1.homedir)(), (0, template_value_1.templateValue)(ref, envs)) };
|
|
70
62
|
}
|
|
71
63
|
const reads = `${owner} reads ${label} from ${secret.from}`;
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
const provider = (0, secret_catalog_1.declared)(catalog.providers, kind);
|
|
65
|
+
if (!provider) {
|
|
66
|
+
throw new Error(unknownProviderMessage(catalog, reads, kind));
|
|
67
|
+
}
|
|
74
68
|
const providerRef = (0, template_value_1.templateValue)(ref, envs);
|
|
75
69
|
if (providerRef.length === 0 || providerRef.startsWith('-')) {
|
|
76
70
|
throw new Error(`${reads}: a reference for ${kind} must not be empty or start with -`);
|
|
77
71
|
}
|
|
78
|
-
const unavailable = (reason, error) => ({
|
|
79
|
-
type: 'unavailable',
|
|
80
|
-
from: secret.from,
|
|
81
|
-
reason: `${label} from ${secret.from}: ${reason}`,
|
|
82
|
-
error,
|
|
83
|
-
});
|
|
84
|
-
const server = !!catalog.explicitAccounts;
|
|
85
|
-
const provider = (0, secret_catalog_1.declared)(catalog.providers, kind);
|
|
86
|
-
if (!provider) {
|
|
87
|
-
return unavailable(server ? `this server has no secret provider ${kind}` : `no secret provider ${kind} is declared`, unknownProviderMessage(catalog, reads, kind));
|
|
88
|
-
}
|
|
89
72
|
const accountName = catalog.explicitAccounts
|
|
90
73
|
? secret.account
|
|
91
74
|
: secret.account ?? taskAccount ?? Object.values(catalog.accounts).find((a) => a.default)?.name;
|
|
92
75
|
if (!accountName) {
|
|
93
|
-
|
|
76
|
+
throw new Error(missingAccountMessage(catalog, reads, owner));
|
|
94
77
|
}
|
|
95
78
|
const account = (0, secret_catalog_1.declared)(catalog.accounts, accountName);
|
|
96
79
|
if (!account) {
|
|
97
80
|
const namedBy = secret.account ? 'the account: of the secret' : `the account: of ${owner}`;
|
|
98
|
-
|
|
81
|
+
throw new Error(unknownAccountMessage(catalog, reads, owner, accountName, namedBy, kind));
|
|
99
82
|
}
|
|
100
83
|
const credentials = (0, secret_catalog_1.declared)(account.providers, kind);
|
|
101
84
|
if (!credentials) {
|
|
102
|
-
|
|
85
|
+
throw new Error(missingCredentialsMessage(catalog, reads, account, kind));
|
|
103
86
|
}
|
|
104
87
|
return {
|
|
105
88
|
type: 'provider',
|
|
@@ -127,9 +110,10 @@ function listDeclared(definitions, server) {
|
|
|
127
110
|
}
|
|
128
111
|
return [...byFile.entries()].map(([file, names]) => `${names.join(', ')} in ${file}`).join(' and ');
|
|
129
112
|
}
|
|
130
|
-
//
|
|
113
|
+
// A build file is checked as a whole when it is read, so one wrong secret stops
|
|
114
|
+
// the tasks that don't read it, too.
|
|
131
115
|
function seeDocs(anchor) {
|
|
132
|
-
return `See ${SECRET_PROVIDERS_DOCS}#${anchor}`;
|
|
116
|
+
return `Every task of the build file is checked when it is read, so this stops other tasks too. See ${SECRET_PROVIDERS_DOCS}#${anchor}`;
|
|
133
117
|
}
|
|
134
118
|
function hostConfigOf(catalog) {
|
|
135
119
|
return catalog.hostConfig ?? 'the host config';
|
|
@@ -229,9 +213,6 @@ function missingCredentialsMessage(catalog, reads, account, provider) {
|
|
|
229
213
|
].join('\n');
|
|
230
214
|
}
|
|
231
215
|
function readSecretValueSync(secret, environment) {
|
|
232
|
-
if (secret.source.type === 'unavailable') {
|
|
233
|
-
throw new Error(secret.source.error);
|
|
234
|
-
}
|
|
235
216
|
if (secret.source.type === 'env') {
|
|
236
217
|
const value = environment.processEnvs[secret.source.name];
|
|
237
218
|
if (value === undefined || value === null) {
|
|
@@ -258,9 +239,6 @@ function readSecretValueSync(secret, environment) {
|
|
|
258
239
|
// The value, read when the task or service starts (or when a cache-affecting
|
|
259
240
|
// secret is hashed); a missing source fails naming the secret.
|
|
260
241
|
async function resolveSecretValue(secret, environment) {
|
|
261
|
-
if (secret.source.type === 'unavailable') {
|
|
262
|
-
throw new Error(secret.source.error);
|
|
263
|
-
}
|
|
264
242
|
if (secret.source.type === 'env') {
|
|
265
243
|
const value = environment.processEnvs[secret.source.name];
|
|
266
244
|
if (value === undefined || value === null) {
|
|
@@ -1,41 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getWorkServiceId = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const work_service_1 = require("./work-service");
|
|
6
6
|
const portable_path_1 = require("./utils/portable-path");
|
|
7
7
|
const plan_work_volume_1 = require("./utils/plan-work-volume");
|
|
8
|
-
// The id of a service: its name in the work tree and what it runs from. Two services of
|
|
9
|
-
// one build file may run the same image from the same directory and differ only in their
|
|
10
|
-
// command, envs or network (an app's api and its worker); the name gives each its own
|
|
11
|
-
// container, Deployment, claim and NetworkPolicy. What the service runs is left out, so
|
|
12
|
-
// a service whose command changed is found again and recreated (getServiceDefinitionHash).
|
|
13
|
-
function getWorkServiceId(service) {
|
|
14
|
-
return hashServiceId({ name: service.name, ...getServiceShape(service) });
|
|
15
|
-
}
|
|
16
|
-
exports.getWorkServiceId = getWorkServiceId;
|
|
17
|
-
// The id without the name, which is all the id was up to 2.0. A task that needs the service
|
|
18
|
-
// caches by it (getWorkServiceCacheIdentity): to the task, a renamed service is the same.
|
|
19
|
-
// A container or Deployment an earlier version started carries it (getLegacyServiceItem).
|
|
20
|
-
function getUnnamedWorkServiceId(service) {
|
|
21
|
-
return hashServiceId(getServiceShape(service));
|
|
22
|
-
}
|
|
23
|
-
exports.getUnnamedWorkServiceId = getUnnamedWorkServiceId;
|
|
24
|
-
// The service under the id an earlier version labeled what it started with. A container or
|
|
25
|
-
// Deployment of it goes once, and the service starts anew under its own id, instead of
|
|
26
|
-
// beside the old one on the same host ports, where neither `up` nor `down` would find it.
|
|
27
|
-
function getLegacyServiceItem(item) {
|
|
28
|
-
return { ...item, id: () => getUnnamedWorkServiceId(item.data) };
|
|
29
|
-
}
|
|
30
|
-
exports.getLegacyServiceItem = getLegacyServiceItem;
|
|
31
|
-
function hashServiceId(shape) {
|
|
32
|
-
return (0, crypto_1.createHash)('sha1').update(JSON.stringify(shape)).digest('hex');
|
|
33
|
-
}
|
|
34
8
|
// Paths are made project-relative (portablePath) so a service id is identical
|
|
35
9
|
// wherever the project is checked out, like a task id.
|
|
36
|
-
function
|
|
10
|
+
function getWorkServiceId(service) {
|
|
37
11
|
const portable = (path) => (0, portable_path_1.portablePath)(service.projectRoot, path);
|
|
38
|
-
|
|
12
|
+
const jsonData = JSON.stringify((0, work_service_1.isContainerWorkService)(service)
|
|
39
13
|
? {
|
|
40
14
|
cwd: portable(service.cwd),
|
|
41
15
|
image: service.image,
|
|
@@ -57,6 +31,8 @@ function getServiceShape(service) {
|
|
|
57
31
|
context: service.context,
|
|
58
32
|
selector: service.selector,
|
|
59
33
|
kubeconfig: portable(service.kubeconfig),
|
|
60
|
-
};
|
|
34
|
+
});
|
|
35
|
+
return (0, crypto_1.createHash)('sha1').update(jsonData).digest('hex');
|
|
61
36
|
}
|
|
37
|
+
exports.getWorkServiceId = getWorkServiceId;
|
|
62
38
|
//# sourceMappingURL=work-service-id.js.map
|