@catladder/pipeline 3.7.0 → 3.8.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 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-0-83dd094e" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "v3-8-0-7a8419fc" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
@@ -51,6 +51,7 @@ var getJobOrServiceArgs_1 = require("../utils/getJobOrServiceArgs");
51
51
  var getServiceName_1 = require("../utils/getServiceName");
52
52
  var common_1 = require("./common");
53
53
  var constants_1 = require("./constants");
54
+ var healthCheck_1 = require("./healthCheck");
54
55
  var volumes_1 = require("./volumes");
55
56
  var getServiceDeployScript = function (context, service, nameSuffix) {
56
57
  var _a, _b, _c, _d, _e, _f;
@@ -60,7 +61,7 @@ var getServiceDeployScript = function (context, service, nameSuffix) {
60
61
  var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.build.type !== "disabled" ? context.build.config.startCommand : undefined : undefined;
61
62
  var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
62
63
  var fullServiceName = serviceName.concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "");
63
- var argsString = createArgsString_1.createArgsString.apply(void 0, __spreadArray([__assign(__assign({
64
+ var argsString = createArgsString_1.createArgsString.apply(void 0, __spreadArray([__assign(__assign(__assign({
64
65
  // command as empty string resets it to default (uses the image's entrypoint)
65
66
  command: commandArray ? '"' + commandArray.join(",") + '"' : '""',
66
67
  args: (0, getJobOrServiceArgs_1.getCloudRunServiceOrJobArgsArg)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.args)
@@ -87,7 +88,7 @@ var getServiceDeployScript = function (context, service, nameSuffix) {
87
88
  "execution-environment": customConfig === null || customConfig === void 0 ? void 0 : customConfig.executionEnvironment,
88
89
  gpu: customConfig === null || customConfig === void 0 ? void 0 : customConfig.gpu,
89
90
  "gpu-type": customConfig === null || customConfig === void 0 ? void 0 : customConfig.gpuType
90
- })], __read((0, volumes_1.createVolumeConfig)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.volumes, "service")), false));
91
+ }), (0, healthCheck_1.healthCheckCliArgs)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.healthCheck))], __read((0, volumes_1.createVolumeConfig)(customConfig === null || customConfig === void 0 ? void 0 : customConfig.volumes, "service")), false));
91
92
  var version = requiresBeta(customConfig) ? "beta" : undefined;
92
93
  return "".concat((0, common_1.gcloudRunCmd)(version), " deploy ").concat(fullServiceName, " ").concat(argsString);
93
94
  };
@@ -110,5 +111,8 @@ var requiresBeta = function (config) {
110
111
  if (config.gpu && config.gpu > 0) {
111
112
  return true;
112
113
  }
114
+ if (config.healthCheck !== undefined) {
115
+ return true;
116
+ }
113
117
  return false;
114
118
  };
@@ -0,0 +1,5 @@
1
+ import { type DeployConfigCloudRunService } from "../../types";
2
+ export declare function healthCheckCliArgs(healthCheck: DeployConfigCloudRunService["healthCheck"]): {
3
+ "startup-probe": string;
4
+ "liveness-probe": string;
5
+ } | undefined;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
21
+ }
22
+ }
23
+ return ar;
24
+ };
25
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
26
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
+ if (ar || !(i in from)) {
28
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
29
+ ar[i] = from[i];
30
+ }
31
+ }
32
+ return to.concat(ar || Array.prototype.slice.call(from));
33
+ };
34
+ Object.defineProperty(exports, "__esModule", {
35
+ value: true
36
+ });
37
+ exports.healthCheckCliArgs = void 0;
38
+ var types_1 = require("../../types");
39
+ var PORT = 8080;
40
+ function healthCheckCliArgs(healthCheck) {
41
+ var shouldNotSetHealthCheck = healthCheck === undefined;
42
+ if (shouldNotSetHealthCheck) {
43
+ return undefined;
44
+ }
45
+ var shouldUseDefaultProbe = healthCheck === true;
46
+ if (shouldUseDefaultProbe) {
47
+ return {
48
+ "startup-probe": toArgValue(probeToKeyValuePairs(types_1.defaultStartupProbe)),
49
+ "liveness-probe": toArgValue(probeToKeyValuePairs(types_1.defaultLivenessProbe))
50
+ };
51
+ }
52
+ return {
53
+ "startup-probe": toArgValue(probeToKeyValuePairs(healthCheck.startupProbe)),
54
+ "liveness-probe": healthCheck.livenessProbe ? toArgValue(probeToKeyValuePairs(healthCheck.livenessProbe)) : "" // NOTE: empty string ("") removes liveness probe
55
+ };
56
+ }
57
+ exports.healthCheckCliArgs = healthCheckCliArgs;
58
+ function probeToKeyValuePairs(probe) {
59
+ var sharedArgs = Object.entries({
60
+ initialDelaySeconds: probe.initialDelaySeconds,
61
+ timeoutSeconds: probe.timeoutSeconds,
62
+ periodSeconds: probe.periodSeconds,
63
+ failureThreshold: probe.failureThreshold
64
+ });
65
+ switch (probe.type) {
66
+ case "tcp":
67
+ return __spreadArray(__spreadArray([], __read(sharedArgs), false), [["tcpSocket.port", PORT]], false);
68
+ case "http1":
69
+ return __spreadArray(__spreadArray([], __read(sharedArgs), false), [["httpGet.port", PORT], ["httpGet.path", probe.path]], false);
70
+ default:
71
+ probe;
72
+ return [];
73
+ }
74
+ }
75
+ function toArgValue(keyValues) {
76
+ return keyValues.map(function (_a) {
77
+ var _b = __read(_a, 2),
78
+ key = _b[0],
79
+ value = _b[1];
80
+ return "".concat(key, "=").concat(value);
81
+ }).join(",");
82
+ }
@@ -136,7 +136,77 @@ export type DeployConfigCloudRunService = {
136
136
  * args to pass to the command
137
137
  */
138
138
  args?: string[];
139
+ /**
140
+ * Configuration of the health check.
141
+ *
142
+ * When set to `true`, startup and liveness probes will be
143
+ * configured to `defaultStartupProbe` and `defaultLivenessProbe`.
144
+ *
145
+ * When not set, default Cloud Run's health check
146
+ * configuration is used (startup TCP probe and no liveness probe).
147
+ */
148
+ healthCheck?: true | {
149
+ /**
150
+ * Startup probe configuration.
151
+ */
152
+ startupProbe: DeployConfigCloudRunProbe;
153
+ /**
154
+ * Liveness probe configuration.
155
+ * `false` disables the liveness probe.
156
+ */
157
+ livenessProbe: false | DeployConfigCloudRunProbe;
158
+ };
139
159
  } & DeployConfigCloudRunWithVolumes & DeployConfigCloudRunNetworkConfig;
160
+ export declare const defaultStartupProbe: DeployConfigCloudRunProbe;
161
+ export declare const defaultLivenessProbe: DeployConfigCloudRunProbe;
162
+ export type DeployConfigCloudRunProbe = DeployConfigCloudRunHttp1Probe | DeployConfigCloudRunTcpProbe;
163
+ export type DeployConfigCloudRunProbeShared = {
164
+ /**
165
+ * The period in seconds at which to perform the probe.
166
+ * For example 2 to perform the probe every 2 seconds.
167
+ * Specify a value **from 1 second to 240** seconds.
168
+ */
169
+ periodSeconds: number;
170
+ /**
171
+ * The number of seconds to wait after the container has started before performing the first probe.
172
+ * Specify a value **from 0 seconds to 240** seconds.
173
+ */
174
+ initialDelaySeconds: number;
175
+ /**
176
+ * The number of seconds to wait until the probe times out.
177
+ * This value cannot exceed the value specified for `period`.
178
+ * Specify a value **from 1 to 240**.
179
+ */
180
+ timeoutSeconds: number;
181
+ /**
182
+ * The number of times to retry the probe before shutting down the container.
183
+ */
184
+ failureThreshold: number;
185
+ };
186
+ export type DeployConfigCloudRunTcpProbe = DeployConfigCloudRunProbeShared & {
187
+ /**
188
+ * Cloud Run makes a TCP connection to open the TCP Socket on the specified port.
189
+ * If Cloud Run is unable to establish a connection, it indicates a failure.
190
+ */
191
+ type: "tcp";
192
+ };
193
+ export type DeployConfigCloudRunHttp1Probe = DeployConfigCloudRunProbeShared & {
194
+ /**
195
+ * **This will NOT work with http2 enabled services**
196
+ *
197
+ * Cloud Run makes an HTTP GET request to the service health check endpoint (for example, /ready).
198
+ * Any response between 200 and 400 is a success, everything else indicates failure.
199
+ *
200
+ * If a startup probe does not succeed within the specified time (failureThreshold * period), which cannot exceed 240 seconds, the container is shut down.
201
+ *
202
+ * If the HTTP startup probe succeeds within the specified time, and you have enabled liveness probe, the HTTP liveness probe is started.
203
+ */
204
+ type: "http1";
205
+ /**
206
+ * the route path to check for health status of the service starting with a `/`.
207
+ */
208
+ path: string;
209
+ };
140
210
  export type DeployConfigCloudRunNetworkConfig = {
141
211
  network?: string;
142
212
  /**
@@ -1,5 +1,30 @@
1
1
  "use strict";
2
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
+ };
3
13
  Object.defineProperty(exports, "__esModule", {
4
14
  value: true
15
+ });
16
+ exports.defaultLivenessProbe = exports.defaultStartupProbe = void 0;
17
+ exports.defaultStartupProbe = {
18
+ type: "http1",
19
+ path: "/__health",
20
+ initialDelaySeconds: 5,
21
+ timeoutSeconds: 1,
22
+ periodSeconds: 30,
23
+ failureThreshold: 3
24
+ };
25
+ exports.defaultLivenessProbe = __assign(__assign({}, exports.defaultStartupProbe), {
26
+ initialDelaySeconds: 0,
27
+ timeoutSeconds: 10,
28
+ periodSeconds: 30,
29
+ failureThreshold: 3
5
30
  });