Skip to content

Commit 31cb9ac

Browse files
feat(serverless): add health check spec to containers (#1544)
Co-authored-by: Laure-di <[email protected]>
1 parent 778b4aa commit 31cb9ac

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

packages/clients/src/api/container/v1beta1/index.gen.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export { API } from './api.gen'
44
export * from './content.gen'
55
export type {
66
Container,
7+
ContainerHealthCheckSpec,
8+
ContainerHealthCheckSpecHTTPProbe,
9+
ContainerHealthCheckSpecTCPProbe,
710
ContainerHttpOption,
811
ContainerPrivacy,
912
ContainerProtocol,

packages/clients/src/api/container/v1beta1/marshalling.gen.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
import type { DefaultValues } from '../../../bridge'
1111
import type {
1212
Container,
13+
ContainerHealthCheckSpec,
14+
ContainerHealthCheckSpecHTTPProbe,
15+
ContainerHealthCheckSpecTCPProbe,
1316
ContainerScalingOption,
1417
CreateContainerRequest,
1518
CreateCronRequest,
@@ -43,6 +46,53 @@ import type {
4346
UpdateTriggerRequestSqsClientConfig,
4447
} from './types.gen'
4548

49+
const unmarshalContainerHealthCheckSpecHTTPProbe = (
50+
data: unknown,
51+
): ContainerHealthCheckSpecHTTPProbe => {
52+
if (!isJSONObject(data)) {
53+
throw new TypeError(
54+
`Unmarshalling the type 'ContainerHealthCheckSpecHTTPProbe' failed as data isn't a dictionary.`,
55+
)
56+
}
57+
58+
return {
59+
path: data.path,
60+
} as ContainerHealthCheckSpecHTTPProbe
61+
}
62+
63+
const unmarshalContainerHealthCheckSpecTCPProbe = (
64+
data: unknown,
65+
): ContainerHealthCheckSpecTCPProbe => {
66+
if (!isJSONObject(data)) {
67+
throw new TypeError(
68+
`Unmarshalling the type 'ContainerHealthCheckSpecTCPProbe' failed as data isn't a dictionary.`,
69+
)
70+
}
71+
72+
return {} as ContainerHealthCheckSpecTCPProbe
73+
}
74+
75+
const unmarshalContainerHealthCheckSpec = (
76+
data: unknown,
77+
): ContainerHealthCheckSpec => {
78+
if (!isJSONObject(data)) {
79+
throw new TypeError(
80+
`Unmarshalling the type 'ContainerHealthCheckSpec' failed as data isn't a dictionary.`,
81+
)
82+
}
83+
84+
return {
85+
failureThreshold: data.failure_threshold,
86+
http: data.http
87+
? unmarshalContainerHealthCheckSpecHTTPProbe(data.http)
88+
: undefined,
89+
interval: data.interval,
90+
tcp: data.tcp
91+
? unmarshalContainerHealthCheckSpecTCPProbe(data.tcp)
92+
: undefined,
93+
} as ContainerHealthCheckSpec
94+
}
95+
4696
const unmarshalContainerScalingOption = (
4797
data: unknown,
4898
): ContainerScalingOption => {
@@ -85,6 +135,9 @@ export const unmarshalContainer = (data: unknown): Container => {
85135
domainName: data.domain_name,
86136
environmentVariables: data.environment_variables,
87137
errorMessage: data.error_message,
138+
healthCheck: data.health_check
139+
? unmarshalContainerHealthCheckSpec(data.health_check)
140+
: undefined,
88141
httpOption: data.http_option,
89142
id: data.id,
90143
localStorageLimit: data.local_storage_limit,
@@ -363,6 +416,42 @@ export const unmarshalListTriggersResponse = (
363416
} as ListTriggersResponse
364417
}
365418

419+
const marshalContainerHealthCheckSpecHTTPProbe = (
420+
request: ContainerHealthCheckSpecHTTPProbe,
421+
defaults: DefaultValues,
422+
): Record<string, unknown> => ({
423+
path: request.path,
424+
})
425+
426+
const marshalContainerHealthCheckSpecTCPProbe = (
427+
request: ContainerHealthCheckSpecTCPProbe,
428+
defaults: DefaultValues,
429+
): Record<string, unknown> => ({})
430+
431+
const marshalContainerHealthCheckSpec = (
432+
request: ContainerHealthCheckSpec,
433+
defaults: DefaultValues,
434+
): Record<string, unknown> => ({
435+
failure_threshold: request.failureThreshold,
436+
interval: request.interval,
437+
...resolveOneOf([
438+
{
439+
param: 'http',
440+
value:
441+
request.http !== undefined
442+
? marshalContainerHealthCheckSpecHTTPProbe(request.http, defaults)
443+
: undefined,
444+
},
445+
{
446+
param: 'tcp',
447+
value:
448+
request.tcp !== undefined
449+
? marshalContainerHealthCheckSpecTCPProbe(request.tcp, defaults)
450+
: undefined,
451+
},
452+
]),
453+
})
454+
366455
const marshalContainerScalingOption = (
367456
request: ContainerScalingOption,
368457
defaults: DefaultValues,
@@ -391,6 +480,10 @@ export const marshalCreateContainerRequest = (
391480
cpu_limit: request.cpuLimit,
392481
description: request.description,
393482
environment_variables: request.environmentVariables,
483+
health_check:
484+
request.healthCheck !== undefined
485+
? marshalContainerHealthCheckSpec(request.healthCheck, defaults)
486+
: undefined,
394487
http_option: request.httpOption,
395488
local_storage_limit: request.localStorageLimit,
396489
max_concurrency: request.maxConcurrency,
@@ -541,6 +634,10 @@ export const marshalUpdateContainerRequest = (
541634
cpu_limit: request.cpuLimit,
542635
description: request.description,
543636
environment_variables: request.environmentVariables,
637+
health_check:
638+
request.healthCheck !== undefined
639+
? marshalContainerHealthCheckSpec(request.healthCheck, defaults)
640+
: undefined,
544641
http_option: request.httpOption,
545642
local_storage_limit: request.localStorageLimit,
546643
max_concurrency: request.maxConcurrency,

packages/clients/src/api/container/v1beta1/types.gen.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,36 @@ export type TriggerStatus =
9595
| 'creating'
9696
| 'pending'
9797

98+
export interface ContainerHealthCheckSpecHTTPProbe {
99+
/** Path to use for the HTTP health check. */
100+
path: string
101+
}
102+
103+
export interface ContainerHealthCheckSpecTCPProbe {}
104+
105+
export interface ContainerHealthCheckSpec {
106+
/**
107+
* HTTP health check configuration.
108+
*
109+
* One-of ('probe'): at most one of 'http', 'tcp' could be set.
110+
*/
111+
http?: ContainerHealthCheckSpecHTTPProbe
112+
/**
113+
* TCP health check configuration.
114+
*
115+
* One-of ('probe'): at most one of 'http', 'tcp' could be set.
116+
*/
117+
tcp?: ContainerHealthCheckSpecTCPProbe
118+
/**
119+
* During a deployment, if a newly created container fails to pass the health
120+
* check, the deployment is aborted. As a result, lowering this value can help
121+
* to reduce the time it takes to detect a failed deployment.
122+
*/
123+
failureThreshold: number
124+
/** Period between health checks. */
125+
interval?: string
126+
}
127+
98128
export interface ContainerScalingOption {
99129
/**
100130
* One-of ('scalingRule'): at most one of 'concurrentRequestsThreshold',
@@ -245,6 +275,8 @@ export interface Container {
245275
* instance.
246276
*/
247277
scalingOption?: ContainerScalingOption
278+
/** Health check configuration of the container. */
279+
healthCheck?: ContainerHealthCheckSpec
248280
/** Creation date of the container. */
249281
createdAt?: Date
250282
/** Last update date of the container. */
@@ -444,6 +476,8 @@ export type CreateContainerRequest = {
444476
* instance.
445477
*/
446478
scalingOption?: ContainerScalingOption
479+
/** Health check configuration of the container. */
480+
healthCheck?: ContainerHealthCheckSpec
447481
}
448482

449483
export type CreateCronRequest = {
@@ -907,6 +941,8 @@ export type UpdateContainerRequest = {
907941
* instance.
908942
*/
909943
scalingOption?: ContainerScalingOption
944+
/** Health check configuration of the container. */
945+
healthCheck?: ContainerHealthCheckSpec
910946
}
911947

912948
export type UpdateCronRequest = {

packages/clients/src/api/container/v1beta1/validation-rules.gen.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
// This file was automatically generated. DO NOT EDIT.
22
// If you have any remark or suggestion do not hesitate to open an issue.
33

4+
export const ContainerHealthCheckSpec = {
5+
failureThreshold: {
6+
greaterThanOrEqual: 3,
7+
lessThanOrEqual: 50,
8+
},
9+
}
10+
11+
export const ContainerHealthCheckSpecHTTPProbe = {
12+
path: {
13+
maxLength: 100,
14+
minLength: 1,
15+
},
16+
}
17+
418
export const ContainerScalingOption = {}
519

620
export const CreateTriggerRequest = {

0 commit comments

Comments
 (0)