Skip to content

Commit

Permalink
Simplify ProbeHandler type
Browse files Browse the repository at this point in the history
  • Loading branch information
kabicin authored and kabicin committed Dec 6, 2023
1 parent 2e4be45 commit 30c28af
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 158 deletions.
12 changes: 0 additions & 12 deletions bundle/manifests/rc.app.stacks_runtimecomponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3088,8 +3088,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3237,8 +3235,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3387,8 +3383,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -10270,8 +10264,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -10419,8 +10411,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -10569,8 +10559,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down
33 changes: 11 additions & 22 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
// GetDefaultMicroProfileStartupProbe returns the default values for MicroProfile Health-based startup probe.
func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *BaseComponentProbe {
port := intstr.FromInt(int(ba.GetService().GetPort()))
periodSeconds := int32(10)
timeoutSeconds := int32(2)
failureThreshold := int32(20)
return &BaseComponentProbe{
BaseComponentProbeHandler: BaseComponentProbeHandler{
HTTPGet: &OptionalHTTPGetAction{
Expand All @@ -18,19 +15,15 @@ func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *BaseComponentProbe {
Scheme: "HTTPS",
},
},
PeriodSeconds: &periodSeconds,
TimeoutSeconds: &timeoutSeconds,
FailureThreshold: &failureThreshold,
PeriodSeconds: 10,
TimeoutSeconds: 2,
FailureThreshold: 20,
}
}

// GetDefaultMicroProfileReadinessProbe returns the default values for MicroProfile Health-based readiness probe.
func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *BaseComponentProbe {
port := intstr.FromInt(int(ba.GetService().GetPort()))
initialDelaySeconds := int32(10)
periodSeconds := int32(10)
timeoutSeconds := int32(2)
failureThreshold := int32(20)
return &BaseComponentProbe{
BaseComponentProbeHandler: BaseComponentProbeHandler{
HTTPGet: &OptionalHTTPGetAction{
Expand All @@ -39,20 +32,16 @@ func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *BaseComponentProbe
Scheme: "HTTPS",
},
},
InitialDelaySeconds: &initialDelaySeconds,
PeriodSeconds: &periodSeconds,
TimeoutSeconds: &timeoutSeconds,
FailureThreshold: &failureThreshold,
InitialDelaySeconds: 10,
PeriodSeconds: 10,
TimeoutSeconds: 2,
FailureThreshold: 10,
}
}

// GetDefaultMicroProfileLivenessProbe returns the default values for MicroProfile Health-based liveness probe.
func GetDefaultMicroProfileLivenessProbe(ba BaseComponent) *BaseComponentProbe {
port := intstr.FromInt(int(ba.GetService().GetPort()))
initialDelaySeconds := int32(60)
periodSeconds := int32(10)
timeoutSeconds := int32(2)
failureThreshold := int32(3)
return &BaseComponentProbe{
BaseComponentProbeHandler: BaseComponentProbeHandler{
HTTPGet: &OptionalHTTPGetAction{
Expand All @@ -61,10 +50,10 @@ func GetDefaultMicroProfileLivenessProbe(ba BaseComponent) *BaseComponentProbe {
Scheme: "HTTPS",
},
},
InitialDelaySeconds: &initialDelaySeconds,
PeriodSeconds: &periodSeconds,
TimeoutSeconds: &timeoutSeconds,
FailureThreshold: &failureThreshold,
InitialDelaySeconds: 60,
PeriodSeconds: 10,
TimeoutSeconds: 2,
FailureThreshold: 3,
}
}

Expand Down
22 changes: 11 additions & 11 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,24 @@ type BaseComponentProbe struct {
// Number of seconds after the container has started before liveness probes are initiated.
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
// +optional
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
// Number of seconds after which the probe times out.
// Defaults to nil.
// Defaults to 1 second. Minimum value is 1.
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
// +optional
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
// How often (in seconds) to perform the probe.
// Defaults to nil.
// Default to 10 seconds. Minimum value is 1.
// +optional
PeriodSeconds *int32 `json:"periodSeconds,omitempty"`
PeriodSeconds int32 `json:"periodSeconds,omitempty"`
// Minimum consecutive successes for the probe to be considered successful after having failed.
// Defaults to nil.
// Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.
// +optional
SuccessThreshold *int32 `json:"successThreshold,omitempty"`
SuccessThreshold int32 `json:"successThreshold,omitempty"`
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
// Defaults to nil.
// Defaults to 3. Minimum value is 1.
// +optional
FailureThreshold *int32 `json:"failureThreshold,omitempty"`
FailureThreshold int32 `json:"failureThreshold,omitempty"`
// Optional duration in seconds the pod needs to terminate gracefully upon probe failure.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with a kill signal.
Expand All @@ -210,7 +210,7 @@ type BaseComponentProbe struct {
// Value must be non-negative integer. The value zero indicates stop immediately via
// the kill signal (no opportunity to shut down).
// This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate.
// Defaults to nil
// Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.
// +optional
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
}
Expand Down Expand Up @@ -245,7 +245,7 @@ type OptionalHTTPGetAction struct {
// Number must be in the range 1 to 65535.
// Name must be an IANA_SVC_NAME.
// +optional
Port *intstr.IntOrString `json:"port"`
Port *intstr.IntOrString `json:"port,omitempty"`
// Host name to connect to, defaults to the pod IP. You probably want to set
// "Host" in httpHeaders instead.
// +optional
Expand Down
25 changes: 0 additions & 25 deletions common/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 30c28af

Please sign in to comment.