Skip to content

Commit 927e6ee

Browse files
kabicinKirby Chin
authored andcommitted
Simplify ProbeHandler type
1 parent 7f6b8d6 commit 927e6ee

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
@@ -3130,8 +3130,6 @@ spec:
31303130
description: Scheme to use for connecting to the host.
31313131
Defaults to HTTP.
31323132
type: string
3133-
required:
3134-
- port
31353133
type: object
31363134
initialDelaySeconds:
31373135
description: 'Number of seconds after the container has started
@@ -3281,8 +3279,6 @@ spec:
32813279
description: Scheme to use for connecting to the host.
32823280
Defaults to HTTP.
32833281
type: string
3284-
required:
3285-
- port
32863282
type: object
32873283
initialDelaySeconds:
32883284
description: 'Number of seconds after the container has started
@@ -3433,8 +3429,6 @@ spec:
34333429
description: Scheme to use for connecting to the host.
34343430
Defaults to HTTP.
34353431
type: string
3436-
required:
3437-
- port
34383432
type: object
34393433
initialDelaySeconds:
34403434
description: 'Number of seconds after the container has started
@@ -10500,8 +10494,6 @@ spec:
1050010494
description: Scheme to use for connecting to the host.
1050110495
Defaults to HTTP.
1050210496
type: string
10503-
required:
10504-
- port
1050510497
type: object
1050610498
initialDelaySeconds:
1050710499
description: 'Number of seconds after the container has started
@@ -10651,8 +10643,6 @@ spec:
1065110643
description: Scheme to use for connecting to the host.
1065210644
Defaults to HTTP.
1065310645
type: string
10654-
required:
10655-
- port
1065610646
type: object
1065710647
initialDelaySeconds:
1065810648
description: 'Number of seconds after the container has started
@@ -10803,8 +10793,6 @@ spec:
1080310793
description: Scheme to use for connecting to the host.
1080410794
Defaults to HTTP.
1080510795
type: string
10806-
required:
10807-
- port
1080810796
type: object
1080910797
initialDelaySeconds:
1081010798
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
@@ -184,24 +184,24 @@ type BaseComponentProbe struct {
184184
// Number of seconds after the container has started before liveness probes are initiated.
185185
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
186186
// +optional
187-
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
187+
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
188188
// Number of seconds after which the probe times out.
189-
// Defaults to nil.
189+
// Defaults to 1 second. Minimum value is 1.
190190
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
191191
// +optional
192-
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
192+
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
193193
// How often (in seconds) to perform the probe.
194-
// Defaults to nil.
194+
// Default to 10 seconds. Minimum value is 1.
195195
// +optional
196-
PeriodSeconds *int32 `json:"periodSeconds,omitempty"`
196+
PeriodSeconds int32 `json:"periodSeconds,omitempty"`
197197
// Minimum consecutive successes for the probe to be considered successful after having failed.
198-
// Defaults to nil.
198+
// Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.
199199
// +optional
200-
SuccessThreshold *int32 `json:"successThreshold,omitempty"`
200+
SuccessThreshold int32 `json:"successThreshold,omitempty"`
201201
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
202-
// Defaults to nil.
202+
// Defaults to 3. Minimum value is 1.
203203
// +optional
204-
FailureThreshold *int32 `json:"failureThreshold,omitempty"`
204+
FailureThreshold int32 `json:"failureThreshold,omitempty"`
205205
// Optional duration in seconds the pod needs to terminate gracefully upon probe failure.
206206
// The grace period is the duration in seconds after the processes running in the pod are sent
207207
// a termination signal and the time when the processes are forcibly halted with a kill signal.
@@ -211,7 +211,7 @@ type BaseComponentProbe struct {
211211
// Value must be non-negative integer. The value zero indicates stop immediately via
212212
// the kill signal (no opportunity to shut down).
213213
// This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate.
214-
// Defaults to nil
214+
// Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.
215215
// +optional
216216
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
217217
}
@@ -246,7 +246,7 @@ type OptionalHTTPGetAction struct {
246246
// Number must be in the range 1 to 65535.
247247
// Name must be an IANA_SVC_NAME.
248248
// +optional
249-
Port *intstr.IntOrString `json:"port"`
249+
Port *intstr.IntOrString `json:"port,omitempty"`
250250
// Host name to connect to, defaults to the pod IP. You probably want to set
251251
// "Host" in httpHeaders instead.
252252
// +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)