@catladder/pipeline 3.42.1 → 3.44.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.
@@ -246,8 +246,6 @@ before_script:
246
246
  - collapseable_section_start "yarninstall" "Yarn install"
247
247
  - yarn install --immutable --inline-builds
248
248
  - collapseable_section_end "yarninstall"
249
- - echo "add healthcheck package"
250
- - meteor add panter:healthroute --allow-superuser
251
249
  - meteor add qualia:prod-shell --allow-superuser
252
250
  - TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory
253
251
  - cp ./__build_info.json ./dist/bundle/programs/server
@@ -737,8 +735,6 @@ before_script:
737
735
  - collapseable_section_start "yarninstall" "Yarn install"
738
736
  - yarn install --immutable --inline-builds
739
737
  - collapseable_section_end "yarninstall"
740
- - echo "add healthcheck package"
741
- - meteor add panter:healthroute --allow-superuser
742
738
  - meteor add qualia:prod-shell --allow-superuser
743
739
  - TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory
744
740
  - cp ./__build_info.json ./dist/bundle/programs/server
@@ -1124,8 +1120,6 @@ before_script:
1124
1120
  - collapseable_section_start "yarninstall" "Yarn install"
1125
1121
  - yarn install --immutable --inline-builds
1126
1122
  - collapseable_section_end "yarninstall"
1127
- - echo "add healthcheck package"
1128
- - meteor add panter:healthroute --allow-superuser
1129
1123
  - meteor add qualia:prod-shell --allow-superuser
1130
1124
  - TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory
1131
1125
  - cp ./__build_info.json ./dist/bundle/programs/server
@@ -1498,8 +1492,6 @@ before_script:
1498
1492
  - collapseable_section_start "yarninstall" "Yarn install"
1499
1493
  - yarn install --immutable --inline-builds
1500
1494
  - collapseable_section_end "yarninstall"
1501
- - echo "add healthcheck package"
1502
- - meteor add panter:healthroute --allow-superuser
1503
1495
  - meteor add qualia:prod-shell --allow-superuser
1504
1496
  - TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory
1505
1497
  - cp ./__build_info.json ./dist/bundle/programs/server
@@ -13,15 +13,14 @@ const config = {
13
13
  type: "google-cloudrun",
14
14
  projectId: "google-project-id",
15
15
  region: "europe-west6",
16
- additionalServices: {
16
+ // worker pools are like services, but they don't have a load balanced endpoint and don't support autoscaling.
17
+ // But they are 40% cheaper than services.
18
+ workerPools: {
17
19
  // its usually better to create another catladder component for the worker
18
- // but in some legacy cases it might be easier to add an extra service
20
+ // but in some legacy cases it might be easier to add service or worker pool
19
21
  // notice that you can't use different secrets on the worker, it will receive the same env vars as the normal service
20
22
  // you can specify extra vars though
21
23
  worker: {
22
- noCpuThrottling: true,
23
- maxInstances: 1,
24
- minInstances: 1,
25
24
  command: [
26
25
  "/bin/sh",
27
26
  "-c",
@@ -13,15 +13,14 @@ const config = {
13
13
  type: "google-cloudrun",
14
14
  projectId: "google-project-id",
15
15
  region: "europe-west6",
16
- additionalServices: {
16
+ // worker pools are like services, but they don't have a load balanced endpoint and don't support autoscaling.
17
+ // But they are 40% cheaper than services.
18
+ workerPools: {
17
19
  // its usually better to create another catladder component for the worker
18
- // but in some legacy cases it might be easier to add an extra service
20
+ // but in some legacy cases it might be easier to add service or worker pool
19
21
  // notice that you can't use different secrets on the worker, it will receive the same env vars as the normal service
20
22
  // you can specify extra vars though
21
23
  worker: {
22
- noCpuThrottling: true,
23
- maxInstances: 1,
24
- minInstances: 1,
25
24
  command: "yarn start:worker",
26
25
  },
27
26
  },
@@ -29,7 +28,7 @@ const config = {
29
28
  env: {
30
29
  review: {
31
30
  deploy: {
32
- additionalServices: {
31
+ workerPools: {
33
32
  worker: null, // disable the worker service on review
34
33
  },
35
34
  },
@@ -0,0 +1,12 @@
1
+ import { it, expect } from "vitest";
2
+ import { createYamlLocalPipeline } from "./__utils__/helpers";
3
+ import config from "./cloud-run-worker-pool";
4
+
5
+ /**
6
+ * This test is auto-generated.
7
+ * Modifications will be overwritten on every `yarn test` run!
8
+ */
9
+
10
+ it("matches snapshot for cloud-run-worker-pool local pipeline YAML", async () => {
11
+ expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
12
+ });
@@ -0,0 +1,42 @@
1
+ import type { Config } from "../src";
2
+
3
+ const config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ api: {
8
+ dir: "api",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ deploy: {
13
+ type: "google-cloudrun",
14
+ projectId: "google-project-id",
15
+ region: "europe-west6",
16
+ workerPools: {
17
+ worker: {
18
+ instances: 1, // is the default value
19
+ command: "yarn start:worker",
20
+ cpu: 1,
21
+ memory: "512Mi",
22
+ },
23
+ },
24
+ },
25
+ env: {
26
+ review: {
27
+ deploy: {
28
+ workerPools: {
29
+ worker: null, // disable the worker pool on review
30
+ },
31
+ },
32
+ },
33
+ },
34
+ },
35
+ },
36
+ } satisfies Config;
37
+
38
+ export default config;
39
+
40
+ export const information = {
41
+ title: "Cloud Run: Worker Pool",
42
+ };
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.42.1",
56
+ "version": "3.44.0",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
59
59
  "build": "yarn build:compile && yarn build:inline-variables",
@@ -48,8 +48,6 @@ export const createMeteorBuildJobs = (
48
48
  script: [
49
49
  ...yarnInstall,
50
50
 
51
- 'echo "add healthcheck package"',
52
- "meteor add panter:healthroute --allow-superuser",
53
51
  "meteor add qualia:prod-shell --allow-superuser",
54
52
 
55
53
  'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory',
@@ -0,0 +1,75 @@
1
+ import { getLabels } from "../../../context/getLabels";
2
+ import type { ComponentContext } from "../../../types/context";
3
+
4
+ import type { DeployConfigCloudRunWorkerPool } from "../../types/googleCloudRun";
5
+ import { createArgsString } from "../utils/createArgsString";
6
+ import { getCloudRunServiceOrJobArgsArg } from "../utils/getJobOrServiceArgs";
7
+ import { getServiceName } from "../utils/getServiceName";
8
+ import {
9
+ gcloudRunCmd,
10
+ getCommonCloudRunArgs,
11
+ getCommonDeployArgs,
12
+ makeLabelString,
13
+ } from "./common";
14
+ import { ENV_VARS_FILENAME } from "./constants";
15
+ import { createVolumeConfig } from "./volumes";
16
+
17
+ export const getWorkerPoolDeployScript = (
18
+ context: ComponentContext,
19
+ workerPool: DeployConfigCloudRunWorkerPool,
20
+ nameSuffix: string,
21
+ ) => {
22
+ const commonDeployArgs = getCommonDeployArgs(context);
23
+
24
+ const serviceName = getServiceName(context);
25
+
26
+ const command = workerPool.command;
27
+
28
+ const commandArray = Array.isArray(command) ? command : command.split(" ");
29
+
30
+ const fullWorkerPoolName = `${serviceName}-${nameSuffix}`;
31
+
32
+ const argsString = createArgsString(
33
+ {
34
+ command: '"' + commandArray.join(",") + '"',
35
+ args: getCloudRunServiceOrJobArgsArg(workerPool.args),
36
+ ...commonDeployArgs,
37
+ image: workerPool.image ?? commonDeployArgs.image,
38
+ labels: makeLabelString({
39
+ ...getLabels(context),
40
+ "cloud-run-worker-pool-name": fullWorkerPoolName,
41
+ }),
42
+ "env-vars-file": ENV_VARS_FILENAME,
43
+ instances: workerPool.instances ?? 1,
44
+ cpu: workerPool.cpu ?? 1,
45
+ memory: workerPool.memory ?? "512Mi",
46
+ "vpc-connector": workerPool.vpcConnector,
47
+ "vpc-egress": workerPool.vpcEgress,
48
+ network: workerPool.network,
49
+ subnet: workerPool.subnet,
50
+ gpu: workerPool.gpu,
51
+ "gpu-type": workerPool.gpuType,
52
+ },
53
+ ...createVolumeConfig(workerPool.volumes, "worker-pool"),
54
+ );
55
+
56
+ // Worker pools are in beta and require the beta command
57
+ return `${gcloudRunCmd("beta")} worker-pools deploy ${fullWorkerPoolName} ${argsString}`;
58
+ };
59
+
60
+ export const getWorkerPoolDeleteScript = (
61
+ context: ComponentContext,
62
+ workerPoolSuffix: string,
63
+ ) => {
64
+ const commonArgs = getCommonCloudRunArgs(context);
65
+
66
+ const commonArgsString = createArgsString(commonArgs);
67
+
68
+ const serviceName = getServiceName(context);
69
+
70
+ const fullWorkerPoolName = `${serviceName}-${workerPoolSuffix}`;
71
+
72
+ return [
73
+ `${gcloudRunCmd("beta")} worker-pools delete ${fullWorkerPoolName} ${commonArgsString}`,
74
+ ];
75
+ };
@@ -10,13 +10,17 @@ import { gcloudServiceAccountLoginCommands } from "../utils/gcloudServiceAccount
10
10
  import { getJobCreateScripts } from "./cloudRunJobs";
11
11
  import { getOnDeployExecuteScript } from "./execute/onDeploy";
12
12
  import { getServiceDeployScript } from "./cloudRunServices";
13
+ import { getWorkerPoolDeployScript } from "./cloudRunWorkerPools";
13
14
  import {
14
15
  getCloudRunDeployConfig,
15
16
  setGoogleProjectNumberScript,
16
17
  } from "./common";
17
18
  import { ENV_VARS_FILENAME } from "./constants";
18
19
  import { getCreateScheduleScript } from "./execute/schedules";
19
- import type { DeployConfigCloudRunService } from "../../types";
20
+ import type {
21
+ DeployConfigCloudRunService,
22
+ DeployConfigCloudRunWorkerPool,
23
+ } from "../../types";
20
24
 
21
25
  export function getCloudRunDeployScripts(context: ComponentContext) {
22
26
  const deployConfig = getCloudRunDeployConfig(context);
@@ -61,6 +65,15 @@ export function getCloudRunDeployScripts(context: ComponentContext) {
61
65
  "-" + name,
62
66
  ),
63
67
  ),
68
+ ...Object.entries(deployConfig.workerPools ?? {})
69
+ .filter(([_, workerPool]) => workerPool !== false && workerPool !== null)
70
+ .map(([name, workerPool]) =>
71
+ getWorkerPoolDeployScript(
72
+ context,
73
+ workerPool as DeployConfigCloudRunWorkerPool,
74
+ name,
75
+ ),
76
+ ),
64
77
  ...getOnDeployExecuteScript(context, "postDeploy"),
65
78
  ]),
66
79
  ...collapseableSection(
@@ -7,6 +7,7 @@ import { getDeleteJobsScripts } from "./cloudRunJobs";
7
7
  import { getOnDeployExecuteScript } from "./execute/onDeploy";
8
8
  import { getDeleteSchedulesScript } from "./execute/schedules";
9
9
  import { getServiceDeleteScript } from "./cloudRunServices";
10
+ import { getWorkerPoolDeleteScript } from "./cloudRunWorkerPools";
10
11
  import { getCloudRunDeployConfig } from "./common";
11
12
 
12
13
  export function getCloudRunStopScripts(context: ComponentContext) {
@@ -18,6 +19,9 @@ export function getCloudRunStopScripts(context: ComponentContext) {
18
19
  ...Object.entries(deployConfig.additionalServices ?? {})
19
20
  .filter(([_, service]) => service !== false && service !== null)
20
21
  .flatMap(([name]) => getServiceDeleteScript(context, name)),
22
+ ...Object.entries(deployConfig.workerPools ?? {})
23
+ .filter(([_, workerPool]) => workerPool !== false && workerPool !== null)
24
+ .flatMap(([name]) => getWorkerPoolDeleteScript(context, name)),
21
25
  ...getOnDeployExecuteScript(context, "postStop"),
22
26
  ...getDeleteSchedulesScript(context),
23
27
  ...getDeleteJobsScripts(context),
@@ -3,7 +3,7 @@ import type { keyValuesArg } from "../utils/createArgsString";
3
3
 
4
4
  export const createVolumeConfig = (
5
5
  volumes: DeployConfigCloudRunVolumes | undefined,
6
- type: "service" | "job",
6
+ type: "service" | "job" | "worker-pool",
7
7
  ): keyValuesArg[] => {
8
8
  if (!volumes) {
9
9
  return [];
@@ -436,6 +436,52 @@ export type DeployConfigCloudRunJob =
436
436
  | DeployConfigCloudRunJobNormal
437
437
  | DeployConfigCloudRunJobWithSchedule;
438
438
 
439
+ export type DeployConfigCloudRunWorkerPool = {
440
+ /**
441
+ * command / entrypoint for the worker pool
442
+ */
443
+ command: string | string[];
444
+
445
+ /**
446
+ * number of instances to run. Defaults to 1.
447
+ * Worker pools do not support autoscaling.
448
+ */
449
+ instances?: number;
450
+
451
+ /**
452
+ * CPU limit. Defaults to 1
453
+ */
454
+ cpu?: Cpu;
455
+
456
+ /**
457
+ * memory limit. Defaults to 512Mi
458
+ */
459
+ memory?: Memory;
460
+
461
+ /**
462
+ * the image to use. Defaults to the image from the build.
463
+ */
464
+ image?: string;
465
+
466
+ /**
467
+ * args to pass to the command
468
+ */
469
+ args?: string[];
470
+
471
+ /**
472
+ * Number of GPUs to use. Defaults to 0
473
+ *
474
+ * This is a preview feature and not all regions support it.
475
+ */
476
+ gpu?: number;
477
+
478
+ /**
479
+ * gpu type to use. Refer to https://cloud.google.com/run/docs/configuring/services/gpu#gcloud for defaults
480
+ */
481
+ gpuType?: string;
482
+ } & DeployConfigCloudRunWithVolumes &
483
+ DeployConfigCloudRunNetworkConfig;
484
+
439
485
  export type DeployConfigCloudRun = Omit<DeployConfigBase, "execute"> & {
440
486
  /**
441
487
  * cloud run deployment.
@@ -470,6 +516,15 @@ export type DeployConfigCloudRun = Omit<DeployConfigBase, "execute"> & {
470
516
  [name: string]: DeployConfigCloudRunJob | false | null;
471
517
  };
472
518
 
519
+ /**
520
+ * deploy worker pools for continuous background work.
521
+ * Worker pools are cost-effective alternatives to services for background processing.
522
+ * They don't have a load balanced endpoint and don't support autoscaling.
523
+ */
524
+ workerPools?: {
525
+ [name: string]: DeployConfigCloudRunWorkerPool | false | null;
526
+ };
527
+
473
528
  /**
474
529
  * add cloudSql
475
530
  */