@catladder/pipeline 3.42.1 → 3.43.0
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/constants.js +1 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunWorkerPools.d.ts +4 -0
- package/dist/deploy/cloudRun/createJobs/cloudRunWorkerPools.js +92 -0
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +13 -2
- package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +12 -2
- package/dist/deploy/cloudRun/createJobs/volumes.d.ts +1 -1
- package/dist/deploy/types/googleCloudRun.d.ts +45 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +6 -6
- package/examples/__snapshots__/cloud-run-worker-pool.test.ts.snap +1495 -0
- package/examples/cloud-run-meteor-with-worker.ts +4 -5
- package/examples/cloud-run-with-worker.ts +5 -6
- package/examples/cloud-run-worker-pool.test.ts +12 -0
- package/examples/cloud-run-worker-pool.ts +42 -0
- package/package.json +1 -1
- package/src/deploy/cloudRun/createJobs/cloudRunWorkerPools.ts +75 -0
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +14 -1
- package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +4 -0
- package/src/deploy/cloudRun/createJobs/volumes.ts +1 -1
- package/src/deploy/types/googleCloudRun.ts +55 -0
package/dist/constants.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
7
|
-
exports.PIPELINE_IMAGE_TAG = "v3-
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "v3-43-0-7d3031bf" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComponentContext } from "../../../types/context";
|
|
2
|
+
import type { DeployConfigCloudRunWorkerPool } from "../../types/googleCloudRun";
|
|
3
|
+
export declare const getWorkerPoolDeployScript: (context: ComponentContext, workerPool: DeployConfigCloudRunWorkerPool, nameSuffix: string) => string;
|
|
4
|
+
export declare const getWorkerPoolDeleteScript: (context: ComponentContext, workerPoolSuffix: string) => string[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = this && this.__read || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o),
|
|
17
|
+
r,
|
|
18
|
+
ar = [],
|
|
19
|
+
e;
|
|
20
|
+
try {
|
|
21
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
e = {
|
|
24
|
+
error: error
|
|
25
|
+
};
|
|
26
|
+
} finally {
|
|
27
|
+
try {
|
|
28
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
29
|
+
} finally {
|
|
30
|
+
if (e) throw e.error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
36
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
37
|
+
if (ar || !(i in from)) {
|
|
38
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
39
|
+
ar[i] = from[i];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
47
|
+
exports.getWorkerPoolDeleteScript = exports.getWorkerPoolDeployScript = void 0;
|
|
48
|
+
var getLabels_1 = require("../../../context/getLabels");
|
|
49
|
+
var createArgsString_1 = require("../utils/createArgsString");
|
|
50
|
+
var getJobOrServiceArgs_1 = require("../utils/getJobOrServiceArgs");
|
|
51
|
+
var getServiceName_1 = require("../utils/getServiceName");
|
|
52
|
+
var common_1 = require("./common");
|
|
53
|
+
var constants_1 = require("./constants");
|
|
54
|
+
var volumes_1 = require("./volumes");
|
|
55
|
+
var getWorkerPoolDeployScript = function (context, workerPool, nameSuffix) {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
|
|
58
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
59
|
+
var command = workerPool.command;
|
|
60
|
+
var commandArray = Array.isArray(command) ? command : command.split(" ");
|
|
61
|
+
var fullWorkerPoolName = "".concat(serviceName, "-").concat(nameSuffix);
|
|
62
|
+
var argsString = createArgsString_1.createArgsString.apply(void 0, __spreadArray([__assign(__assign({
|
|
63
|
+
command: '"' + commandArray.join(",") + '"',
|
|
64
|
+
args: (0, getJobOrServiceArgs_1.getCloudRunServiceOrJobArgsArg)(workerPool.args)
|
|
65
|
+
}, commonDeployArgs), {
|
|
66
|
+
image: (_a = workerPool.image) !== null && _a !== void 0 ? _a : commonDeployArgs.image,
|
|
67
|
+
labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
|
|
68
|
+
"cloud-run-worker-pool-name": fullWorkerPoolName
|
|
69
|
+
})),
|
|
70
|
+
"env-vars-file": constants_1.ENV_VARS_FILENAME,
|
|
71
|
+
instances: (_b = workerPool.instances) !== null && _b !== void 0 ? _b : 1,
|
|
72
|
+
cpu: (_c = workerPool.cpu) !== null && _c !== void 0 ? _c : 1,
|
|
73
|
+
memory: (_d = workerPool.memory) !== null && _d !== void 0 ? _d : "512Mi",
|
|
74
|
+
"vpc-connector": workerPool.vpcConnector,
|
|
75
|
+
"vpc-egress": workerPool.vpcEgress,
|
|
76
|
+
network: workerPool.network,
|
|
77
|
+
subnet: workerPool.subnet,
|
|
78
|
+
gpu: workerPool.gpu,
|
|
79
|
+
"gpu-type": workerPool.gpuType
|
|
80
|
+
})], __read((0, volumes_1.createVolumeConfig)(workerPool.volumes, "worker-pool")), false));
|
|
81
|
+
// Worker pools are in beta and require the beta command
|
|
82
|
+
return "".concat((0, common_1.gcloudRunCmd)("beta"), " worker-pools deploy ").concat(fullWorkerPoolName, " ").concat(argsString);
|
|
83
|
+
};
|
|
84
|
+
exports.getWorkerPoolDeployScript = getWorkerPoolDeployScript;
|
|
85
|
+
var getWorkerPoolDeleteScript = function (context, workerPoolSuffix) {
|
|
86
|
+
var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
87
|
+
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
88
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
89
|
+
var fullWorkerPoolName = "".concat(serviceName, "-").concat(workerPoolSuffix);
|
|
90
|
+
return ["".concat((0, common_1.gcloudRunCmd)("beta"), " worker-pools delete ").concat(fullWorkerPoolName, " ").concat(commonArgsString)];
|
|
91
|
+
};
|
|
92
|
+
exports.getWorkerPoolDeleteScript = getWorkerPoolDeleteScript;
|
|
@@ -45,14 +45,15 @@ var gcloudServiceAccountLoginCommands_1 = require("../utils/gcloudServiceAccount
|
|
|
45
45
|
var cloudRunJobs_1 = require("./cloudRunJobs");
|
|
46
46
|
var onDeploy_1 = require("./execute/onDeploy");
|
|
47
47
|
var cloudRunServices_1 = require("./cloudRunServices");
|
|
48
|
+
var cloudRunWorkerPools_1 = require("./cloudRunWorkerPools");
|
|
48
49
|
var common_1 = require("./common");
|
|
49
50
|
var constants_1 = require("./constants");
|
|
50
51
|
var schedules_1 = require("./execute/schedules");
|
|
51
52
|
function getCloudRunDeployScripts(context) {
|
|
52
|
-
var _a;
|
|
53
|
+
var _a, _b;
|
|
53
54
|
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
54
55
|
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
55
|
-
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read((0, common_1.setGoogleProjectNumberScript)(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("writeenvvars", "Write env vars to file")((0, bashYaml_1.writeBashYamlToFileScript)(allEnvVars, constants_1.ENV_VARS_FILENAME))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
56
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read((0, common_1.setGoogleProjectNumberScript)(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("writeenvvars", "Write env vars to file")((0, bashYaml_1.writeBashYamlToFileScript)(allEnvVars, constants_1.ENV_VARS_FILENAME))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
56
57
|
: []), false), __read((0, schedules_1.getCreateScheduleScript)(context)), false), __read((0, cloudRunJobs_1.getJobCreateScripts)(context)), false), __read((0, onDeploy_1.getOnDeployExecuteScript)(context, "preDeploy")), false), __read(deployConfig.service !== false ? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)] : []), false), __read(Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).filter(function (_a) {
|
|
57
58
|
var _b = __read(_a, 2),
|
|
58
59
|
_ = _b[0],
|
|
@@ -63,6 +64,16 @@ function getCloudRunDeployScripts(context) {
|
|
|
63
64
|
name = _b[0],
|
|
64
65
|
service = _b[1];
|
|
65
66
|
return (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name);
|
|
67
|
+
})), false), __read(Object.entries((_b = deployConfig.workerPools) !== null && _b !== void 0 ? _b : {}).filter(function (_a) {
|
|
68
|
+
var _b = __read(_a, 2),
|
|
69
|
+
_ = _b[0],
|
|
70
|
+
workerPool = _b[1];
|
|
71
|
+
return workerPool !== false && workerPool !== null;
|
|
72
|
+
}).map(function (_a) {
|
|
73
|
+
var _b = __read(_a, 2),
|
|
74
|
+
name = _b[0],
|
|
75
|
+
workerPool = _b[1];
|
|
76
|
+
return (0, cloudRunWorkerPools_1.getWorkerPoolDeployScript)(context, workerPool, name);
|
|
66
77
|
})), false), __read((0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy")), false))), false), __read((0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy"))), false);
|
|
67
78
|
}
|
|
68
79
|
exports.getCloudRunDeployScripts = getCloudRunDeployScripts;
|
|
@@ -42,11 +42,12 @@ var cloudRunJobs_1 = require("./cloudRunJobs");
|
|
|
42
42
|
var onDeploy_1 = require("./execute/onDeploy");
|
|
43
43
|
var schedules_1 = require("./execute/schedules");
|
|
44
44
|
var cloudRunServices_1 = require("./cloudRunServices");
|
|
45
|
+
var cloudRunWorkerPools_1 = require("./cloudRunWorkerPools");
|
|
45
46
|
var common_1 = require("./common");
|
|
46
47
|
function getCloudRunStopScripts(context) {
|
|
47
|
-
var _a;
|
|
48
|
+
var _a, _b;
|
|
48
49
|
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
49
|
-
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read((0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop")), false), __read(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []), false), __read(Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).filter(function (_a) {
|
|
50
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read((0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop")), false), __read(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []), false), __read(Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).filter(function (_a) {
|
|
50
51
|
var _b = __read(_a, 2),
|
|
51
52
|
_ = _b[0],
|
|
52
53
|
service = _b[1];
|
|
@@ -55,6 +56,15 @@ function getCloudRunStopScripts(context) {
|
|
|
55
56
|
var _b = __read(_a, 1),
|
|
56
57
|
name = _b[0];
|
|
57
58
|
return (0, cloudRunServices_1.getServiceDeleteScript)(context, name);
|
|
59
|
+
})), false), __read(Object.entries((_b = deployConfig.workerPools) !== null && _b !== void 0 ? _b : {}).filter(function (_a) {
|
|
60
|
+
var _b = __read(_a, 2),
|
|
61
|
+
_ = _b[0],
|
|
62
|
+
workerPool = _b[1];
|
|
63
|
+
return workerPool !== false && workerPool !== null;
|
|
64
|
+
}).flatMap(function (_a) {
|
|
65
|
+
var _b = __read(_a, 1),
|
|
66
|
+
name = _b[0];
|
|
67
|
+
return (0, cloudRunWorkerPools_1.getWorkerPoolDeleteScript)(context, name);
|
|
58
68
|
})), false), __read((0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop")), false), __read((0, schedules_1.getDeleteSchedulesScript)(context)), false), __read((0, cloudRunJobs_1.getDeleteJobsScripts)(context)), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false);
|
|
59
69
|
}
|
|
60
70
|
exports.getCloudRunStopScripts = getCloudRunStopScripts;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DeployConfigCloudRunVolumes } from "../../types";
|
|
2
2
|
import type { keyValuesArg } from "../utils/createArgsString";
|
|
3
|
-
export declare const createVolumeConfig: (volumes: DeployConfigCloudRunVolumes | undefined, type: "service" | "job") => keyValuesArg[];
|
|
3
|
+
export declare const createVolumeConfig: (volumes: DeployConfigCloudRunVolumes | undefined, type: "service" | "job" | "worker-pool") => keyValuesArg[];
|
|
@@ -323,6 +323,43 @@ export type DeployConfigCloudRunWithVolumes = {
|
|
|
323
323
|
volumes?: DeployConfigCloudRunVolumes;
|
|
324
324
|
};
|
|
325
325
|
export type DeployConfigCloudRunJob = DeployConfigCloudRunJobNormal | DeployConfigCloudRunJobWithSchedule;
|
|
326
|
+
export type DeployConfigCloudRunWorkerPool = {
|
|
327
|
+
/**
|
|
328
|
+
* command / entrypoint for the worker pool
|
|
329
|
+
*/
|
|
330
|
+
command: string | string[];
|
|
331
|
+
/**
|
|
332
|
+
* number of instances to run. Defaults to 1.
|
|
333
|
+
* Worker pools do not support autoscaling.
|
|
334
|
+
*/
|
|
335
|
+
instances?: number;
|
|
336
|
+
/**
|
|
337
|
+
* CPU limit. Defaults to 1
|
|
338
|
+
*/
|
|
339
|
+
cpu?: Cpu;
|
|
340
|
+
/**
|
|
341
|
+
* memory limit. Defaults to 512Mi
|
|
342
|
+
*/
|
|
343
|
+
memory?: Memory;
|
|
344
|
+
/**
|
|
345
|
+
* the image to use. Defaults to the image from the build.
|
|
346
|
+
*/
|
|
347
|
+
image?: string;
|
|
348
|
+
/**
|
|
349
|
+
* args to pass to the command
|
|
350
|
+
*/
|
|
351
|
+
args?: string[];
|
|
352
|
+
/**
|
|
353
|
+
* Number of GPUs to use. Defaults to 0
|
|
354
|
+
*
|
|
355
|
+
* This is a preview feature and not all regions support it.
|
|
356
|
+
*/
|
|
357
|
+
gpu?: number;
|
|
358
|
+
/**
|
|
359
|
+
* gpu type to use. Refer to https://cloud.google.com/run/docs/configuring/services/gpu#gcloud for defaults
|
|
360
|
+
*/
|
|
361
|
+
gpuType?: string;
|
|
362
|
+
} & DeployConfigCloudRunWithVolumes & DeployConfigCloudRunNetworkConfig;
|
|
326
363
|
export type DeployConfigCloudRun = Omit<DeployConfigBase, "execute"> & {
|
|
327
364
|
/**
|
|
328
365
|
* cloud run deployment.
|
|
@@ -353,6 +390,14 @@ export type DeployConfigCloudRun = Omit<DeployConfigBase, "execute"> & {
|
|
|
353
390
|
jobs?: {
|
|
354
391
|
[name: string]: DeployConfigCloudRunJob | false | null;
|
|
355
392
|
};
|
|
393
|
+
/**
|
|
394
|
+
* deploy worker pools for continuous background work.
|
|
395
|
+
* Worker pools are cost-effective alternatives to services for background processing.
|
|
396
|
+
* They don't have a load balanced endpoint and don't support autoscaling.
|
|
397
|
+
*/
|
|
398
|
+
workerPools?: {
|
|
399
|
+
[name: string]: DeployConfigCloudRunWorkerPool | false | null;
|
|
400
|
+
};
|
|
356
401
|
/**
|
|
357
402
|
* add cloudSql
|
|
358
403
|
*/
|