Skip to content

Commit 30c28af

Browse files
kabicinkabicin
authored andcommitted
Simplify ProbeHandler type
1 parent 2e4be45 commit 30c28af

File tree

8 files changed

+81
-158
lines changed

8 files changed

+81
-158
lines changed

bundle/manifests/rc.app.stacks_runtimecomponents.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,8 +3088,6 @@ spec:
30883088
description: Scheme to use for connecting to the host.
30893089
Defaults to HTTP.
30903090
type: string
3091-
required:
3092-
- port
30933091
type: object
30943092
initialDelaySeconds:
30953093
description: 'Number of seconds after the container has started
@@ -3237,8 +3235,6 @@ spec:
32373235
description: Scheme to use for connecting to the host.
32383236
Defaults to HTTP.
32393237
type: string
3240-
required:
3241-
- port
32423238
type: object
32433239
initialDelaySeconds:
32443240
description: 'Number of seconds after the container has started
@@ -3387,8 +3383,6 @@ spec:
33873383
description: Scheme to use for connecting to the host.
33883384
Defaults to HTTP.
33893385
type: string
3390-
required:
3391-
- port
33923386
type: object
33933387
initialDelaySeconds:
33943388
description: 'Number of seconds after the container has started
@@ -10270,8 +10264,6 @@ spec:
1027010264
description: Scheme to use for connecting to the host.
1027110265
Defaults to HTTP.
1027210266
type: string
10273-
required:
10274-
- port
1027510267
type: object
1027610268
initialDelaySeconds:
1027710269
description: 'Number of seconds after the container has started
@@ -10419,8 +10411,6 @@ spec:
1041910411
description: Scheme to use for connecting to the host.
1042010412
Defaults to HTTP.
1042110413
type: string
10422-
required:
10423-
- port
1042410414
type: object
1042510415
initialDelaySeconds:
1042610416
description: 'Number of seconds after the container has started
@@ -10569,8 +10559,6 @@ spec:
1056910559
description: Scheme to use for connecting to the host.
1057010560
Defaults to HTTP.
1057110561
type: string
10572-
required:
10573-
- port
1057410562
type: object
1057510563
initialDelaySeconds:
1057610564
description: 'Number of seconds after the container has started

common/common.go

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import (
77
// GetDefaultMicroProfileStartupProbe returns the default values for MicroProfile Health-based startup probe.
88
func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *BaseComponentProbe {
99
port := intstr.FromInt(int(ba.GetService().GetPort()))
10-
periodSeconds := int32(10)
11-
timeoutSeconds := int32(2)
12-
failureThreshold := int32(20)
1310
return &BaseComponentProbe{
1411
BaseComponentProbeHandler: BaseComponentProbeHandler{
1512
HTTPGet: &OptionalHTTPGetAction{
@@ -18,19 +15,15 @@ func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *BaseComponentProbe {
1815
Scheme: "HTTPS",
1916
},
2017
},
21-
PeriodSeconds: &periodSeconds,
22-
TimeoutSeconds: &timeoutSeconds,
23-
FailureThreshold: &failureThreshold,
18+
PeriodSeconds: 10,
19+
TimeoutSeconds: 2,
20+
FailureThreshold: 20,
2421
}
2522
}
2623

2724
// GetDefaultMicroProfileReadinessProbe returns the default values for MicroProfile Health-based readiness probe.
2825
func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *BaseComponentProbe {
2926
port := intstr.FromInt(int(ba.GetService().GetPort()))
30-
initialDelaySeconds := int32(10)
31-
periodSeconds := int32(10)
32-
timeoutSeconds := int32(2)
33-
failureThreshold := int32(20)
3427
return &BaseComponentProbe{
3528
BaseComponentProbeHandler: BaseComponentProbeHandler{
3629
HTTPGet: &OptionalHTTPGetAction{
@@ -39,20 +32,16 @@ func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *BaseComponentProbe
3932
Scheme: "HTTPS",
4033
},
4134
},
42-
InitialDelaySeconds: &initialDelaySeconds,
43-
PeriodSeconds: &periodSeconds,
44-
TimeoutSeconds: &timeoutSeconds,
45-
FailureThreshold: &failureThreshold,
35+
InitialDelaySeconds: 10,
36+
PeriodSeconds: 10,
37+
TimeoutSeconds: 2,
38+
FailureThreshold: 10,
4639
}
4740
}
4841

4942
// GetDefaultMicroProfileLivenessProbe returns the default values for MicroProfile Health-based liveness probe.
5043
func GetDefaultMicroProfileLivenessProbe(ba BaseComponent) *BaseComponentProbe {
5144
port := intstr.FromInt(int(ba.GetService().GetPort()))
52-
initialDelaySeconds := int32(60)
53-
periodSeconds := int32(10)
54-
timeoutSeconds := int32(2)
55-
failureThreshold := int32(3)
5645
return &BaseComponentProbe{
5746
BaseComponentProbeHandler: BaseComponentProbeHandler{
5847
HTTPGet: &OptionalHTTPGetAction{
@@ -61,10 +50,10 @@ func GetDefaultMicroProfileLivenessProbe(ba BaseComponent) *BaseComponentProbe {
6150
Scheme: "HTTPS",
6251
},
6352
},
64-
InitialDelaySeconds: &initialDelaySeconds,
65-
PeriodSeconds: &periodSeconds,
66-
TimeoutSeconds: &timeoutSeconds,
67-
FailureThreshold: &failureThreshold,
53+
InitialDelaySeconds: 60,
54+
PeriodSeconds: 10,
55+
TimeoutSeconds: 2,
56+
FailureThreshold: 3,
6857
}
6958
}
7059

common/types.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,24 @@ type BaseComponentProbe struct {
183183
// Number of seconds after the container has started before liveness probes are initiated.
184184
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
185185
// +optional
186-
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
186+
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
187187
// Number of seconds after which the probe times out.
188-
// Defaults to nil.
188+
// Defaults to 1 second. Minimum value is 1.
189189
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
190190
// +optional
191-
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
191+
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
192192
// How often (in seconds) to perform the probe.
193-
// Defaults to nil.
193+
// Default to 10 seconds. Minimum value is 1.
194194
// +optional
195-
PeriodSeconds *int32 `json:"periodSeconds,omitempty"`
195+
PeriodSeconds int32 `json:"periodSeconds,omitempty"`
196196
// Minimum consecutive successes for the probe to be considered successful after having failed.
197-
// Defaults to nil.
197+
// Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.
198198
// +optional
199-
SuccessThreshold *int32 `json:"successThreshold,omitempty"`
199+
SuccessThreshold int32 `json:"successThreshold,omitempty"`
200200
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
201-
// Defaults to nil.
201+
// Defaults to 3. Minimum value is 1.
202202
// +optional
203-
FailureThreshold *int32 `json:"failureThreshold,omitempty"`
203+
FailureThreshold int32 `json:"failureThreshold,omitempty"`
204204
// Optional duration in seconds the pod needs to terminate gracefully upon probe failure.
205205
// The grace period is the duration in seconds after the processes running in the pod are sent
206206
// a termination signal and the time when the processes are forcibly halted with a kill signal.
@@ -210,7 +210,7 @@ type BaseComponentProbe struct {
210210
// Value must be non-negative integer. The value zero indicates stop immediately via
211211
// the kill signal (no opportunity to shut down).
212212
// This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate.
213-
// Defaults to nil
213+
// Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.
214214
// +optional
215215
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
216216
}
@@ -245,7 +245,7 @@ type OptionalHTTPGetAction struct {
245245
// Number must be in the range 1 to 65535.
246246
// Name must be an IANA_SVC_NAME.
247247
// +optional
248-
Port *intstr.IntOrString `json:"port"`
248+
Port *intstr.IntOrString `json:"port,omitempty"`
249249
// Host name to connect to, defaults to the pod IP. You probably want to set
250250
// "Host" in httpHeaders instead.
251251
// +optional

common/zz_generated.deepcopy.go

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)