@toa.io/operations 1.0.0-alpha.234 → 1.0.0-alpha.239

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/operations",
3
- "version": "1.0.0-alpha.234",
3
+ "version": "1.0.0-alpha.239",
4
4
  "description": "Toa Deployment",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -29,10 +29,10 @@
29
29
  "dependencies": {
30
30
  "@toa.io/filesystem": "1.0.0-alpha.225",
31
31
  "@toa.io/generic": "1.0.0-alpha.225",
32
- "@toa.io/norm": "1.0.0-alpha.228",
32
+ "@toa.io/norm": "1.0.0-alpha.239",
33
33
  "@toa.io/yaml": "1.0.0-alpha.225",
34
34
  "execa": "5.1.1",
35
35
  "fs-extra": "11.1.1"
36
36
  },
37
- "gitHead": "0a102917aca0115eadc2410f0a7836e3e40096a0"
37
+ "gitHead": "35935a713890e680fccbd23f77570da2bc12fd64"
38
38
  }
@@ -7,6 +7,9 @@ function compositions (compositions, dependency) {
7
7
  for (const composition of compositions) {
8
8
  addVariables(composition, dependency.variables)
9
9
  addMounts(composition, dependency.mounts)
10
+
11
+ if (dependency.probe !== undefined && dependency.probe !== false)
12
+ composition.probe ??= dependency.probe
10
13
  }
11
14
  }
12
15
 
@@ -2,9 +2,14 @@
2
2
 
3
3
  const { addVariables } = require('./variables')
4
4
 
5
- function services (services, variables) {
5
+ function services (services, variables, probe) {
6
6
  for (const service of services) {
7
7
  addVariables(service, variables)
8
+
9
+ if (service.probe === false)
10
+ delete service.probe
11
+ else if (service.probe === undefined && probe !== undefined && probe !== false)
12
+ service.probe = probe
8
13
  }
9
14
  }
10
15
 
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  function addVariables (composition, variables) {
4
- const used = new Set()
5
-
6
4
  composition.variables ??= []
7
5
 
6
+ const used = new Set(composition.variables.map((variable) => variable.name))
7
+
8
8
  for (const [key, set] of Object.entries(variables)) {
9
9
  if (key !== 'global' && !composition.components?.includes(key))
10
10
  continue
@@ -21,7 +21,7 @@ const describe = (context, compositions, dependency) => {
21
21
  const credentials = context.registry?.credentials
22
22
 
23
23
  desc.compositions(compositions, dependency)
24
- desc.services(services, dependency.variables)
24
+ desc.services(services, dependency.variables, dependency.probe)
25
25
 
26
26
  return {
27
27
  compositions,
@@ -15,15 +15,19 @@ const merge = (dependencies) => {
15
15
 
16
16
  const mounts = {}
17
17
 
18
+ /** @type {toa.deployment.dependency.Probe | false | undefined} */
19
+ let probe
20
+
18
21
  for (const dependency of dependencies) {
19
22
  if (dependency.references !== undefined) references.push(...dependency.references)
20
23
  if (dependency.services !== undefined) services.push(...dependency.services)
21
24
  if (dependency.proxies !== undefined) proxies.push(...dependency.proxies)
22
25
  if (dependency.variables !== undefined) append(variables, dependency.variables)
23
26
  if (dependency.mounts !== undefined) append(mounts, dependency.mounts)
27
+ if (dependency.probe !== undefined) probe = dependency.probe
24
28
  }
25
29
 
26
- return { references, services, proxies, variables, mounts }
30
+ return { references, services, proxies, variables, mounts, probe }
27
31
  }
28
32
 
29
33
  const append = (merged, variables) => {
@@ -47,6 +47,27 @@ spec:
47
47
  {{- include "env.var" . | indent 12 }}
48
48
  {{- end }}
49
49
  {{- end }}
50
+ {{- if .probe }}
51
+ ports:
52
+ - containerPort: {{ .probe.port }}
53
+ startupProbe:
54
+ httpGet:
55
+ path: {{ .probe.path }}
56
+ port: {{ .probe.port }}
57
+ {{- if .probe.delay }}
58
+ initialDelaySeconds: {{ .probe.delay }}
59
+ {{- end }}
60
+ periodSeconds: 2
61
+ timeoutSeconds: 3
62
+ failureThreshold: 150
63
+ readinessProbe:
64
+ httpGet:
65
+ path: {{ .probe.path }}
66
+ port: {{ .probe.port }}
67
+ periodSeconds: 10
68
+ timeoutSeconds: 3
69
+ failureThreshold: 3
70
+ {{- end }}
50
71
  {{- if .mounts }}
51
72
  volumeMounts:
52
73
  {{- range .mounts }}
@@ -54,6 +75,11 @@ spec:
54
75
  mountPath: {{ .path }}
55
76
  {{- end }}
56
77
  {{- end }}
78
+ lifecycle:
79
+ preStop:
80
+ exec:
81
+ command: [sleep, "5"]
82
+ terminationGracePeriodSeconds: 45
57
83
  {{- if $.Values.credentials }}
58
84
  imagePullSecrets:
59
85
  - name: {{ $.Values.credentials }}
@@ -10,7 +10,7 @@ export interface Service {
10
10
  resources?: Resources
11
11
  variables?: Variable[]
12
12
  components?: string[]
13
- probe?: Probe
13
+ probe?: Probe | false
14
14
  }
15
15
 
16
16
  export interface Variable {
@@ -38,6 +38,8 @@ export interface Dependency {
38
38
  services?: Service[]
39
39
  variables?: Variables
40
40
  mounts?: Mounts
41
+ /** Default probe for compositions and services without their own probe. `false` disables. */
42
+ probe?: Probe | false
41
43
  }
42
44
 
43
45
  interface Ingress {
@@ -47,7 +49,7 @@ interface Ingress {
47
49
  annotations?: object
48
50
  }
49
51
 
50
- interface Probe {
52
+ export interface Probe {
51
53
  port: number
52
54
  path: string
53
55
  delay?: number