veryfront 0.1.628 → 0.1.630
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/esm/cli/commands/worker/command-help.d.ts.map +1 -1
- package/esm/cli/commands/worker/command-help.js +0 -5
- package/esm/cli/commands/worker/command.d.ts.map +1 -1
- package/esm/cli/commands/worker/command.js +0 -6
- package/esm/cli/commands/worker/handler.js +1 -1
- package/esm/deno.d.ts +9 -0
- package/esm/deno.js +16 -7
- package/esm/src/agent/composition/composition.d.ts +0 -1
- package/esm/src/agent/composition/composition.d.ts.map +1 -1
- package/esm/src/agent/composition/composition.js +15 -1
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +9 -1
- package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts +2 -2
- package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/operations.js +2 -2
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.d.ts +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.js +1 -1
- package/esm/src/server/dev-server/file-watch-setup.d.ts +15 -0
- package/esm/src/server/dev-server/file-watch-setup.d.ts.map +1 -1
- package/esm/src/server/dev-server/file-watch-setup.js +61 -4
- package/esm/src/server/handlers/request/project-run-execute.handler.d.ts +74 -0
- package/esm/src/server/handlers/request/project-run-execute.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/project-run-execute.handler.js +460 -0
- package/esm/src/server/runtime-handler/index.d.ts +1 -1
- package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.js +3 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/workflow/worker/executors/index.d.ts +0 -2
- package/esm/src/workflow/worker/executors/index.d.ts.map +1 -1
- package/esm/src/workflow/worker/executors/index.js +0 -2
- package/esm/src/workflow/worker/executors/types.d.ts +7 -17
- package/esm/src/workflow/worker/executors/types.d.ts.map +1 -1
- package/esm/src/workflow/worker/executors/types.js +0 -1
- package/esm/src/workflow/worker/index.d.ts +3 -9
- package/esm/src/workflow/worker/index.d.ts.map +1 -1
- package/esm/src/workflow/worker/index.js +3 -9
- package/esm/src/workflow/worker/run-manager.d.ts +1 -16
- package/esm/src/workflow/worker/run-manager.d.ts.map +1 -1
- package/esm/src/workflow/worker/run-manager.js +2 -19
- package/package.json +1 -1
- package/esm/src/workflow/worker/executors/k8s.d.ts +0 -157
- package/esm/src/workflow/worker/executors/k8s.d.ts.map +0 -1
- package/esm/src/workflow/worker/executors/k8s.js +0 -198
|
@@ -3,22 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides distributed workflow execution support.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Two execution profiles are available:
|
|
7
7
|
*
|
|
8
8
|
* 1. **WorkflowWorker** - In-process polling worker
|
|
9
9
|
* - Polls for stalled workflows and resumes them
|
|
10
10
|
* - Good for trusted code or single-tenant deployments
|
|
11
11
|
* - Simple setup, lower overhead
|
|
12
12
|
*
|
|
13
|
-
* 2. **WorkflowRunManager +
|
|
14
|
-
* - Each workflow runs in an ephemeral container
|
|
15
|
-
* - Complete tenant isolation (no shared state)
|
|
16
|
-
* - Required for multi-tenant untrusted code execution
|
|
17
|
-
*
|
|
18
|
-
* 3. **WorkflowRunManager + ProcessRunExecutor** - Local process execution
|
|
13
|
+
* 2. **WorkflowRunManager + ProcessRunExecutor** - Local process execution
|
|
19
14
|
* - Spawns child processes for each workflow
|
|
20
15
|
* - Good for local development without K8s/Docker
|
|
21
|
-
* - Mirrors production behavior
|
|
22
16
|
*
|
|
23
17
|
* A workflow run can be backed by a run executor without introducing another
|
|
24
18
|
* user-visible execution type.
|
|
@@ -29,7 +23,7 @@ export { createWorkflowWorker, WorkflowWorker, } from "./workflow-worker.js";
|
|
|
29
23
|
// Isolated workflow run execution (multi-tenant / untrusted code)
|
|
30
24
|
export { createWorkflowRunManager, WorkflowRunManager, } from "./run-manager.js";
|
|
31
25
|
// Run executors (pluggable runtime backends)
|
|
32
|
-
export { isRunExecutor,
|
|
26
|
+
export { isRunExecutor, ProcessRunExecutor, } from "./executors/index.js";
|
|
33
27
|
// Workflow run entrypoint (runs inside ephemeral container/process)
|
|
34
28
|
// Use this when workflows are pre-bundled in the container
|
|
35
29
|
export { createWorkflowRunEntrypoint, EXIT_CODES, runWorkflowRun, } from "./run-entrypoint.js";
|
|
@@ -7,7 +7,7 @@ export type { RunExecutionInfo, RunExecutionStatus, RunExecutor } from "./execut
|
|
|
7
7
|
export interface WorkflowRunManagerConfig {
|
|
8
8
|
/** Backend for workflow persistence */
|
|
9
9
|
backend: WorkflowBackend;
|
|
10
|
-
/** Run executor
|
|
10
|
+
/** Run executor used to start isolated workflow processes */
|
|
11
11
|
executor: RunExecutor;
|
|
12
12
|
/** Environment variables to inject into run executions */
|
|
13
13
|
env?: Record<string, string>;
|
|
@@ -57,21 +57,6 @@ interface TrackedExecution {
|
|
|
57
57
|
* Orchestrates workflow execution via pluggable run executors.
|
|
58
58
|
* Each workflow runs in complete isolation.
|
|
59
59
|
*
|
|
60
|
-
* @example K8s
|
|
61
|
-
* ```typescript
|
|
62
|
-
* const executor = new K8sRunExecutor({
|
|
63
|
-
* image: "my-app:latest",
|
|
64
|
-
* namespace: "workflows",
|
|
65
|
-
* }, k8sClient);
|
|
66
|
-
*
|
|
67
|
-
* const manager = new WorkflowRunManager({
|
|
68
|
-
* backend: redisBackend,
|
|
69
|
-
* executor,
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* manager.start();
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
60
|
* @example Local Process
|
|
76
61
|
* ```typescript
|
|
77
62
|
* const executor = new ProcessRunExecutor({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-manager.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/run-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-manager.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/run-manager.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG9F,OAAO,KAAK,EAAsB,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAehG,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9F;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,OAAO,EAAE,eAAe,CAAC;IAEzB,6DAA6D;IAC7D,QAAQ,EAAE,WAAW,CAAC;IAEtB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,wCAAwC;IACxC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,IAAI,CAAC;CACjB;AAOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,WAAW,CAAC,CAAwC;IAC5D,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,wBAAwB;IAuB5C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B3B;;OAEG;IACH,QAAQ,IAAI,YAAY;IAIxB;;OAEG;IACH,mBAAmB,IAAI,gBAAgB,EAAE;IAIzC;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;YACW,IAAI;IAyGlB;;OAEG;YACW,wBAAwB;IAuCtC;;OAEG;YACW,0BAA0B;IAoDxC;;OAEG;IACH,OAAO,CAAC,WAAW;CAIpB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,wBAAwB,GAC/B,kBAAkB,CAEpB"}
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
* Orchestrates workflow run execution via isolated run executors.
|
|
5
5
|
* Uses pluggable RunExecutor interface for runtime flexibility.
|
|
6
6
|
*
|
|
7
|
-
* Supported
|
|
8
|
-
* -
|
|
9
|
-
* - ProcessRunExecutor: Child processes (local dev)
|
|
10
|
-
* - DockerRunExecutor: Docker containers (future)
|
|
7
|
+
* Supported runtime:
|
|
8
|
+
* - ProcessRunExecutor: Child processes for local development and trusted hosts
|
|
11
9
|
*
|
|
12
10
|
* Key properties:
|
|
13
11
|
* - Each workflow runs in isolation (no shared state)
|
|
@@ -32,21 +30,6 @@ const DEFAULT_STALLED_THRESHOLD_MS = 60_000;
|
|
|
32
30
|
* Orchestrates workflow execution via pluggable run executors.
|
|
33
31
|
* Each workflow runs in complete isolation.
|
|
34
32
|
*
|
|
35
|
-
* @example K8s
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const executor = new K8sRunExecutor({
|
|
38
|
-
* image: "my-app:latest",
|
|
39
|
-
* namespace: "workflows",
|
|
40
|
-
* }, k8sClient);
|
|
41
|
-
*
|
|
42
|
-
* const manager = new WorkflowRunManager({
|
|
43
|
-
* backend: redisBackend,
|
|
44
|
-
* executor,
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* manager.start();
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
33
|
* @example Local Process
|
|
51
34
|
* ```typescript
|
|
52
35
|
* const executor = new ProcessRunExecutor({
|
package/package.json
CHANGED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kubernetes-backed run executor
|
|
3
|
-
*
|
|
4
|
-
* Executes workflow runs as Kubernetes Job resources.
|
|
5
|
-
* Each workflow runs in an ephemeral pod with complete isolation.
|
|
6
|
-
*/
|
|
7
|
-
import type { RunExecutionConfig, RunExecutionInfo, RunExecutor } from "./types.js";
|
|
8
|
-
/**
|
|
9
|
-
* Kubernetes-backed run executor configuration
|
|
10
|
-
*/
|
|
11
|
-
export interface K8sRunExecutorConfig {
|
|
12
|
-
/** Kubernetes namespace for run executions */
|
|
13
|
-
namespace?: string;
|
|
14
|
-
/** Container image for workflow execution */
|
|
15
|
-
image: string;
|
|
16
|
-
/** Image pull policy */
|
|
17
|
-
imagePullPolicy?: "Always" | "IfNotPresent" | "Never";
|
|
18
|
-
/** Service account for run executions */
|
|
19
|
-
serviceAccount?: string;
|
|
20
|
-
/** Resource requests/limits for run execution pods */
|
|
21
|
-
resources?: {
|
|
22
|
-
requests?: {
|
|
23
|
-
cpu?: string;
|
|
24
|
-
memory?: string;
|
|
25
|
-
};
|
|
26
|
-
limits?: {
|
|
27
|
-
cpu?: string;
|
|
28
|
-
memory?: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
/** Secrets to mount as environment variables */
|
|
32
|
-
envFromSecrets?: string[];
|
|
33
|
-
/** Time to keep completed run executions for debugging (seconds) */
|
|
34
|
-
ttlAfterFinished?: number;
|
|
35
|
-
/** Enable debug logging */
|
|
36
|
-
debug?: boolean;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Kubernetes API client interface
|
|
40
|
-
*/
|
|
41
|
-
export interface K8sClient {
|
|
42
|
-
/** Create a run execution Kubernetes resource */
|
|
43
|
-
createRunExecution(namespace: string, resource: K8sRunExecutionSpec): Promise<void>;
|
|
44
|
-
/** Get Kubernetes resource status */
|
|
45
|
-
getRunExecutionResource(namespace: string, name: string): Promise<K8sRunExecutionStatusResponse | null>;
|
|
46
|
-
/** List run execution Kubernetes resources with label selector */
|
|
47
|
-
listRunExecutions(namespace: string, labelSelector: string): Promise<K8sRunExecutionStatusResponse[]>;
|
|
48
|
-
/** Delete a run execution Kubernetes resource */
|
|
49
|
-
deleteRunExecution(namespace: string, name: string): Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* K8s run execution Kubernetes resource spec
|
|
53
|
-
*/
|
|
54
|
-
export interface K8sRunExecutionSpec {
|
|
55
|
-
metadata: {
|
|
56
|
-
name: string;
|
|
57
|
-
namespace: string;
|
|
58
|
-
labels: Record<string, string>;
|
|
59
|
-
};
|
|
60
|
-
spec: {
|
|
61
|
-
ttlSecondsAfterFinished?: number;
|
|
62
|
-
activeDeadlineSeconds?: number;
|
|
63
|
-
backoffLimit: number;
|
|
64
|
-
template: {
|
|
65
|
-
metadata: {
|
|
66
|
-
labels: Record<string, string>;
|
|
67
|
-
};
|
|
68
|
-
spec: {
|
|
69
|
-
restartPolicy: "Never" | "OnFailure";
|
|
70
|
-
serviceAccountName?: string;
|
|
71
|
-
containers: Array<{
|
|
72
|
-
name: string;
|
|
73
|
-
image: string;
|
|
74
|
-
imagePullPolicy?: string;
|
|
75
|
-
env?: Array<{
|
|
76
|
-
name: string;
|
|
77
|
-
value?: string;
|
|
78
|
-
valueFrom?: unknown;
|
|
79
|
-
}>;
|
|
80
|
-
envFrom?: Array<{
|
|
81
|
-
secretRef?: {
|
|
82
|
-
name: string;
|
|
83
|
-
};
|
|
84
|
-
}>;
|
|
85
|
-
resources?: {
|
|
86
|
-
requests?: {
|
|
87
|
-
cpu?: string;
|
|
88
|
-
memory?: string;
|
|
89
|
-
};
|
|
90
|
-
limits?: {
|
|
91
|
-
cpu?: string;
|
|
92
|
-
memory?: string;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
command?: string[];
|
|
96
|
-
args?: string[];
|
|
97
|
-
}>;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* K8s run execution status response
|
|
104
|
-
*/
|
|
105
|
-
export interface K8sRunExecutionStatusResponse {
|
|
106
|
-
metadata: {
|
|
107
|
-
name: string;
|
|
108
|
-
labels: Record<string, string>;
|
|
109
|
-
creationTimestamp: string;
|
|
110
|
-
};
|
|
111
|
-
status: {
|
|
112
|
-
active?: number;
|
|
113
|
-
succeeded?: number;
|
|
114
|
-
failed?: number;
|
|
115
|
-
startTime?: string;
|
|
116
|
-
completionTime?: string;
|
|
117
|
-
conditions?: Array<{
|
|
118
|
-
type: string;
|
|
119
|
-
status: string;
|
|
120
|
-
reason?: string;
|
|
121
|
-
message?: string;
|
|
122
|
-
}>;
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Kubernetes-backed run executor
|
|
127
|
-
*/
|
|
128
|
-
export declare class K8sRunExecutor implements RunExecutor {
|
|
129
|
-
private config;
|
|
130
|
-
private k8sClient;
|
|
131
|
-
constructor(config: K8sRunExecutorConfig, k8sClient: K8sClient);
|
|
132
|
-
createRunExecution(executionConfig: RunExecutionConfig): Promise<string>;
|
|
133
|
-
getRunExecutionStatus(executionId: string): Promise<RunExecutionInfo | null>;
|
|
134
|
-
listRunExecutions(managerId: string): Promise<RunExecutionInfo[]>;
|
|
135
|
-
deleteRunExecution(executionId: string): Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* Convert execution ID to a valid K8s resource name
|
|
138
|
-
*/
|
|
139
|
-
private sanitizeResourceName;
|
|
140
|
-
/**
|
|
141
|
-
* Build tenant environment variables
|
|
142
|
-
*/
|
|
143
|
-
private buildTenantEnv;
|
|
144
|
-
/**
|
|
145
|
-
* Parse K8s run execution response to RunExecutionInfo
|
|
146
|
-
*/
|
|
147
|
-
private parseRunExecutionInfo;
|
|
148
|
-
/**
|
|
149
|
-
* Parse K8s run execution status
|
|
150
|
-
*/
|
|
151
|
-
private parseStatus;
|
|
152
|
-
/**
|
|
153
|
-
* Extract error from K8s run execution
|
|
154
|
-
*/
|
|
155
|
-
private extractError;
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=k8s.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"k8s.d.ts","sourceRoot":"","sources":["../../../../../src/src/workflow/worker/executors/k8s.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAEhB,WAAW,EACZ,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IAEd,wBAAwB;IACxB,eAAe,CAAC,EAA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|
|
2
|
-
* Kubernetes-backed run executor
|
|
3
|
-
*
|
|
4
|
-
* Executes workflow runs as Kubernetes Job resources.
|
|
5
|
-
* Each workflow runs in an ephemeral pod with complete isolation.
|
|
6
|
-
*/
|
|
7
|
-
import { logger as baseLogger } from "../../../utils/index.js";
|
|
8
|
-
const logger = baseLogger.component("k8s-run-executor");
|
|
9
|
-
/** Default TTL for completed K8s Job resources before automatic cleanup (seconds) */
|
|
10
|
-
const DEFAULT_TTL_AFTER_FINISHED_SECONDS = 300;
|
|
11
|
-
/**
|
|
12
|
-
* Kubernetes-backed run executor
|
|
13
|
-
*/
|
|
14
|
-
export class K8sRunExecutor {
|
|
15
|
-
config;
|
|
16
|
-
k8sClient;
|
|
17
|
-
constructor(config, k8sClient) {
|
|
18
|
-
this.k8sClient = k8sClient;
|
|
19
|
-
this.config = {
|
|
20
|
-
namespace: "default",
|
|
21
|
-
imagePullPolicy: "IfNotPresent",
|
|
22
|
-
ttlAfterFinished: DEFAULT_TTL_AFTER_FINISHED_SECONDS,
|
|
23
|
-
debug: false,
|
|
24
|
-
...config,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
async createRunExecution(executionConfig) {
|
|
28
|
-
const { executionId, run, managerId, timeout, env, debug } = executionConfig;
|
|
29
|
-
const resourceName = this.sanitizeResourceName(executionId);
|
|
30
|
-
const tenantSlug = run._tenant?.projectSlug ?? "unknown";
|
|
31
|
-
const resource = {
|
|
32
|
-
metadata: {
|
|
33
|
-
name: resourceName,
|
|
34
|
-
namespace: this.config.namespace,
|
|
35
|
-
labels: {
|
|
36
|
-
"veryfront.com/component": "workflow-run-execution",
|
|
37
|
-
"veryfront.com/manager": managerId,
|
|
38
|
-
"veryfront.com/execution-id": executionId,
|
|
39
|
-
"veryfront.com/run-id": run.id,
|
|
40
|
-
"veryfront.com/workflow-id": run.workflowId,
|
|
41
|
-
"veryfront.com/tenant": tenantSlug,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
spec: {
|
|
45
|
-
ttlSecondsAfterFinished: this.config.ttlAfterFinished,
|
|
46
|
-
activeDeadlineSeconds: Math.floor(timeout / 1000),
|
|
47
|
-
backoffLimit: 0,
|
|
48
|
-
template: {
|
|
49
|
-
metadata: {
|
|
50
|
-
labels: {
|
|
51
|
-
"veryfront.com/component": "workflow-run-execution",
|
|
52
|
-
"veryfront.com/execution-id": executionId,
|
|
53
|
-
"veryfront.com/run-id": run.id,
|
|
54
|
-
"veryfront.com/tenant": tenantSlug,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
spec: {
|
|
58
|
-
restartPolicy: "Never",
|
|
59
|
-
serviceAccountName: this.config.serviceAccount,
|
|
60
|
-
containers: [
|
|
61
|
-
{
|
|
62
|
-
name: "workflow",
|
|
63
|
-
image: this.config.image,
|
|
64
|
-
imagePullPolicy: this.config.imagePullPolicy,
|
|
65
|
-
env: [
|
|
66
|
-
{ name: "MODE", value: "run" },
|
|
67
|
-
{ name: "WORKFLOW_RUN_ID", value: run.id },
|
|
68
|
-
{ name: "RUN_EXECUTION_ID", value: executionId },
|
|
69
|
-
...this.buildTenantEnv(run),
|
|
70
|
-
...Object.entries(env).map(([name, value]) => ({ name, value })),
|
|
71
|
-
],
|
|
72
|
-
envFrom: this.config.envFromSecrets?.map((name) => ({
|
|
73
|
-
secretRef: { name },
|
|
74
|
-
})),
|
|
75
|
-
resources: this.config.resources,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
await this.k8sClient.createRunExecution(this.config.namespace, resource);
|
|
83
|
-
if (debug || this.config.debug) {
|
|
84
|
-
logger.info(`Created run execution ${resourceName} for run ${run.id}`);
|
|
85
|
-
}
|
|
86
|
-
return executionId;
|
|
87
|
-
}
|
|
88
|
-
async getRunExecutionStatus(executionId) {
|
|
89
|
-
const resourceName = this.sanitizeResourceName(executionId);
|
|
90
|
-
try {
|
|
91
|
-
const k8sResource = await this.k8sClient.getRunExecutionResource(this.config.namespace, resourceName);
|
|
92
|
-
if (!k8sResource) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return this.parseRunExecutionInfo(k8sResource, executionId);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
logger.debug("Failed to get K8s run execution status", { error });
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async listRunExecutions(managerId) {
|
|
103
|
-
const labelSelector = `veryfront.com/manager=${managerId}`;
|
|
104
|
-
const k8sResources = await this.k8sClient.listRunExecutions(this.config.namespace, labelSelector);
|
|
105
|
-
return k8sResources.map((k8sResource) => {
|
|
106
|
-
const executionId = k8sResource.metadata.labels["veryfront.com/execution-id"] ??
|
|
107
|
-
k8sResource.metadata.name;
|
|
108
|
-
return this.parseRunExecutionInfo(k8sResource, executionId);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
async deleteRunExecution(executionId) {
|
|
112
|
-
const resourceName = this.sanitizeResourceName(executionId);
|
|
113
|
-
try {
|
|
114
|
-
await this.k8sClient.deleteRunExecution(this.config.namespace, resourceName);
|
|
115
|
-
if (this.config.debug) {
|
|
116
|
-
logger.info(`Deleted run execution ${resourceName}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
logger.warn(`Failed to delete run execution ${resourceName}:`, error);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Convert execution ID to a valid K8s resource name
|
|
125
|
-
*/
|
|
126
|
-
sanitizeResourceName(executionId) {
|
|
127
|
-
return `wf-${executionId.replace(/_/g, "-").toLowerCase()}`;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Build tenant environment variables
|
|
131
|
-
*/
|
|
132
|
-
buildTenantEnv(run) {
|
|
133
|
-
if (!run._tenant) {
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
const { projectSlug, token, projectId, productionMode, releaseId, branch, environmentName } = run._tenant;
|
|
137
|
-
const env = [
|
|
138
|
-
{ name: "TENANT_PROJECT_SLUG", value: projectSlug },
|
|
139
|
-
{ name: "TENANT_TOKEN", value: token },
|
|
140
|
-
{ name: "TENANT_PROJECT_ID", value: projectId ?? "" },
|
|
141
|
-
{ name: "TENANT_PRODUCTION_MODE", value: productionMode ? "1" : "0" },
|
|
142
|
-
{ name: "TENANT_RELEASE_ID", value: releaseId ?? "" },
|
|
143
|
-
];
|
|
144
|
-
if (branch) {
|
|
145
|
-
env.push({ name: "TENANT_BRANCH_ID", value: branch }, { name: "VERYFRONT_BRANCH_REF", value: branch });
|
|
146
|
-
}
|
|
147
|
-
if (environmentName) {
|
|
148
|
-
env.push({ name: "TENANT_ENVIRONMENT_NAME", value: environmentName }, { name: "VERYFRONT_ENVIRONMENT_NAME", value: environmentName });
|
|
149
|
-
}
|
|
150
|
-
return env;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Parse K8s run execution response to RunExecutionInfo
|
|
154
|
-
*/
|
|
155
|
-
parseRunExecutionInfo(k8sResource, executionId) {
|
|
156
|
-
const runId = k8sResource.metadata.labels["veryfront.com/run-id"] ?? "";
|
|
157
|
-
return {
|
|
158
|
-
executionId,
|
|
159
|
-
runId,
|
|
160
|
-
status: this.parseStatus(k8sResource),
|
|
161
|
-
createdAt: new Date(k8sResource.metadata.creationTimestamp),
|
|
162
|
-
startedAt: k8sResource.status.startTime ? new Date(k8sResource.status.startTime) : undefined,
|
|
163
|
-
completedAt: k8sResource.status.completionTime
|
|
164
|
-
? new Date(k8sResource.status.completionTime)
|
|
165
|
-
: undefined,
|
|
166
|
-
error: this.extractError(k8sResource),
|
|
167
|
-
metadata: {
|
|
168
|
-
k8sName: k8sResource.metadata.name,
|
|
169
|
-
namespace: this.config.namespace,
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Parse K8s run execution status
|
|
175
|
-
*/
|
|
176
|
-
parseStatus(k8sResource) {
|
|
177
|
-
if (k8sResource.status.succeeded && k8sResource.status.succeeded > 0) {
|
|
178
|
-
return "succeeded";
|
|
179
|
-
}
|
|
180
|
-
if (k8sResource.status.failed && k8sResource.status.failed > 0) {
|
|
181
|
-
return "failed";
|
|
182
|
-
}
|
|
183
|
-
if (k8sResource.status.active && k8sResource.status.active > 0) {
|
|
184
|
-
return "running";
|
|
185
|
-
}
|
|
186
|
-
return "pending";
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Extract error from K8s run execution
|
|
190
|
-
*/
|
|
191
|
-
extractError(k8sResource) {
|
|
192
|
-
const failedCondition = k8sResource.status.conditions?.find((c) => c.type === "Failed" && c.status === "True");
|
|
193
|
-
if (failedCondition) {
|
|
194
|
-
return failedCondition.message ?? failedCondition.reason ?? "Unknown error";
|
|
195
|
-
}
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
198
|
-
}
|