Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the Probe interface to support optional path, port and scheme properties #566

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a31f9a0
Create BaseComponentProbe as wrapper to corev1.Probe
kabicin Jul 25, 2023
b210960
Make port optional
kabicin Jul 25, 2023
5002432
Override fields using extending operators' default probe
kabicin Jul 26, 2023
cb16ef9
Update utils.go
kabicin Jul 26, 2023
0c78994
Update utils.go
kabicin Jul 26, 2023
b35349c
Set default port to nil
kabicin Jul 26, 2023
9692530
Update zz_generated.deepcopy.go
kabicin Jul 26, 2023
6c68adc
Set values of probes to pointers
kabicin Jul 26, 2023
310180f
Add probe defaults override function to interface
kabicin Jul 26, 2023
0d4066c
Update naming from override to patch
kabicin Jul 26, 2023
0d16ff5
Update runtimecomponent_types.go
kabicin Jul 27, 2023
2405dcb
Cite struct code from k8s impl
kabicin Jul 27, 2023
7f6b8d6
Update types.go
kabicin Jul 27, 2023
927e6ee
Simplify ProbeHandler type
kabicin Oct 5, 2023
3ba549f
Merge branch 'main' into probe-defaults
kabicin Apr 19, 2024
f30075a
Update utils.go
kabicin Apr 22, 2024
b581b08
Merge branch 'probe-defaults' of github.com:application-stacks/runtim…
kabicin Apr 22, 2024
f3350c9
Resolve incorrect default value for optionalHTTPGetAction.Scheme
kabicin Apr 24, 2024
0153a31
Don't make manageTLS affect httpGet.scheme
kabicin Apr 24, 2024
ac6004c
Merge branch 'main' into probe-defaults
kabicin May 6, 2024
fbcd444
Merge branch 'main' into probe-defaults
kabicin May 7, 2024
d7ca862
Merge branch 'main' into probe-defaults
kabicin May 10, 2024
0547cc1
Revert v1beta2 probe changes
kabicin May 10, 2024
2c99928
Use MicroProfile probe defaults and set scheme based on manageTLS
kabicin May 10, 2024
ba95915
Merge branch 'probe-defaults' of github.com:application-stacks/runtim…
kabicin May 10, 2024
eeecf5f
Add common_v1beta2 for v1beta2 API to use deprecated Probes interface
kabicin May 14, 2024
812d075
Remove unused common components from v1beta2
kabicin May 14, 2024
ea15efc
Remove probe patch, centralize probes logic to RCO
kabicin May 15, 2024
9e2fa7a
Pass on HTTPGet attributes from default MP config
kabicin May 16, 2024
e89f9b8
Update utils.go
kabicin May 16, 2024
3364880
Update utils.go
kabicin May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions api/v1/runtimecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ type RuntimeComponentServiceAccount struct {
type RuntimeComponentProbes struct {
// Periodic probe of container liveness. Container will be restarted if the probe fails.
// +operator-sdk:csv:customresourcedefinitions:order=3,type=spec,displayName="Liveness Probe"
Liveness *corev1.Probe `json:"liveness,omitempty"`
Liveness *common.BaseComponentProbe `json:"liveness,omitempty"`

// Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails.
// +operator-sdk:csv:customresourcedefinitions:order=2,type=spec,displayName="Readiness Probe"
Readiness *corev1.Probe `json:"readiness,omitempty"`
Readiness *common.BaseComponentProbe `json:"readiness,omitempty"`

// Probe to determine successful initialization. If specified, other probes are not executed until this completes successfully.
// +operator-sdk:csv:customresourcedefinitions:order=1,type=spec,displayName="Startup Probe"
Startup *corev1.Probe `json:"startup,omitempty"`
Startup *common.BaseComponentProbe `json:"startup,omitempty"`
}

// Configure pods to run on particular Nodes.
Expand Down Expand Up @@ -544,32 +544,32 @@ func (cr *RuntimeComponent) GetProbes() common.BaseComponentProbes {
}

// GetLivenessProbe returns liveness probe
func (p *RuntimeComponentProbes) GetLivenessProbe() *corev1.Probe {
func (p *RuntimeComponentProbes) GetLivenessProbe() *common.BaseComponentProbe {
return p.Liveness
}

// GetReadinessProbe returns readiness probe
func (p *RuntimeComponentProbes) GetReadinessProbe() *corev1.Probe {
func (p *RuntimeComponentProbes) GetReadinessProbe() *common.BaseComponentProbe {
return p.Readiness
}

// GetStartupProbe returns startup probe
func (p *RuntimeComponentProbes) GetStartupProbe() *corev1.Probe {
func (p *RuntimeComponentProbes) GetStartupProbe() *common.BaseComponentProbe {
return p.Startup
}

// GetDefaultLivenessProbe returns default values for liveness probe
func (p *RuntimeComponentProbes) GetDefaultLivenessProbe(ba common.BaseComponent) *corev1.Probe {
func (p *RuntimeComponentProbes) GetDefaultLivenessProbe(ba common.BaseComponent) *common.BaseComponentProbe {
return common.GetDefaultMicroProfileLivenessProbe(ba)
}

// GetDefaultReadinessProbe returns default values for readiness probe
func (p *RuntimeComponentProbes) GetDefaultReadinessProbe(ba common.BaseComponent) *corev1.Probe {
func (p *RuntimeComponentProbes) GetDefaultReadinessProbe(ba common.BaseComponent) *common.BaseComponentProbe {
return common.GetDefaultMicroProfileReadinessProbe(ba)
}

// GetDefaultStartupProbe returns default values for startup probe
func (p *RuntimeComponentProbes) GetDefaultStartupProbe(ba common.BaseComponent) *corev1.Probe {
func (p *RuntimeComponentProbes) GetDefaultStartupProbe(ba common.BaseComponent) *common.BaseComponentProbe {
return common.GetDefaultMicroProfileStartupProbe(ba)
}

Expand Down
6 changes: 3 additions & 3 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion api/v1beta2/runtimecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1beta2
import (
"time"

"github.com/application-stacks/runtime-component-operator/common"
common "github.com/application-stacks/runtime-component-operator/common_v1beta2"
routev1 "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down
6 changes: 0 additions & 6 deletions bundle/manifests/rc.app.stacks_runtimecomponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3144,8 +3144,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 @@ -3295,8 +3293,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 @@ -3447,8 +3443,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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ metadata:
categories: Application Runtime
certified: "true"
containerImage: icr.io/appcafe/runtime-component-operator:daily
createdAt: "2024-05-07T20:25:49Z"
createdAt: "2024-05-16T14:08:31Z"
description: Deploys any runtime component with dynamic and auto-tuning configuration
olm.skipRange: '>=0.8.0 <1.3.2'
operators.openshift.io/infrastructure-features: '["disconnected"]'
Expand Down
34 changes: 18 additions & 16 deletions common/common.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package common

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

// GetDefaultMicroProfileStartupProbe returns the default values for MicroProfile Health-based startup probe.
func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *corev1.Probe {
return &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *BaseComponentProbe {
port := intstr.FromInt(int(ba.GetService().GetPort()))
return &BaseComponentProbe{
BaseComponentProbeHandler: BaseComponentProbeHandler{
HTTPGet: &OptionalHTTPGetAction{
Path: "/health/started",
Port: intstr.FromInt(int(ba.GetService().GetPort())),
Port: &port,
Scheme: "HTTPS",
},
},
Expand All @@ -22,12 +22,13 @@ func GetDefaultMicroProfileStartupProbe(ba BaseComponent) *corev1.Probe {
}

// GetDefaultMicroProfileReadinessProbe returns the default values for MicroProfile Health-based readiness probe.
func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *corev1.Probe {
return &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *BaseComponentProbe {
port := intstr.FromInt(int(ba.GetService().GetPort()))
return &BaseComponentProbe{
BaseComponentProbeHandler: BaseComponentProbeHandler{
HTTPGet: &OptionalHTTPGetAction{
Path: "/health/ready",
Port: intstr.FromInt(int(ba.GetService().GetPort())),
Port: &port,
Scheme: "HTTPS",
},
},
Expand All @@ -39,12 +40,13 @@ func GetDefaultMicroProfileReadinessProbe(ba BaseComponent) *corev1.Probe {
}

// GetDefaultMicroProfileLivenessProbe returns the default values for MicroProfile Health-based liveness probe.
func GetDefaultMicroProfileLivenessProbe(ba BaseComponent) *corev1.Probe {
return &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
func GetDefaultMicroProfileLivenessProbe(ba BaseComponent) *BaseComponentProbe {
port := intstr.FromInt(int(ba.GetService().GetPort()))
return &BaseComponentProbe{
BaseComponentProbeHandler: BaseComponentProbeHandler{
HTTPGet: &OptionalHTTPGetAction{
Path: "/health/live",
Port: intstr.FromInt(int(ba.GetService().GetPort())),
Port: &port,
Scheme: "HTTPS",
},
},
Expand Down
97 changes: 91 additions & 6 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

// StatusConditionType ...
Expand Down Expand Up @@ -177,15 +178,99 @@ type BaseComponentStatefulSet interface {
GetAnnotations() map[string]string
}

// This struct is taken from the Probe specification in https://github.com/kubernetes/api/blob/v0.24.2/core/v1/types.go
// +kubebuilder:object:generate=true
type BaseComponentProbe struct {
// The action taken to determine the health of a container
BaseComponentProbeHandler `json:",inline"`
// 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"`
// Number of seconds after which the probe times out.
// 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"`
// How often (in seconds) to perform the probe.
// Default to 10 seconds. Minimum value is 1.
// +optional
PeriodSeconds int32 `json:"periodSeconds,omitempty"`
// Minimum consecutive successes for the probe to be considered successful after having failed.
// Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.
// +optional
SuccessThreshold int32 `json:"successThreshold,omitempty"`
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
// Defaults to 3. Minimum value is 1.
// +optional
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.
// Set this value longer than the expected cleanup time for your process.
// If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this
// value overrides the value provided by the pod spec.
// 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.
// Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.
// +optional
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
}

// This struct is taken from the ProbeHandler specification in https://github.com/kubernetes/api/blob/v0.24.2/core/v1/types.go
// +kubebuilder:object:generate=true
type BaseComponentProbeHandler struct {
// Exec specifies the action to take.
// +optional
Exec *corev1.ExecAction `json:"exec,omitempty"`
// HTTPGet specifies the http request to perform.
// +optional
HTTPGet *OptionalHTTPGetAction `json:"httpGet,omitempty"`
// TCPSocket specifies an action involving a TCP port.
// +optional
TCPSocket *corev1.TCPSocketAction `json:"tcpSocket,omitempty"`

// GRPC specifies an action involving a GRPC port.
// This is a beta field and requires enabling GRPCContainerProbe feature gate.
// +featureGate=GRPCContainerProbe
// +optional
GRPC *corev1.GRPCAction `json:"grpc,omitempty"`
}

// This struct is based upon the HTTPGetAction specification in https://github.com/kubernetes/api/blob/v0.24.2/core/v1/types.go
// +kubebuilder:object:generate=true
type OptionalHTTPGetAction struct {
// Path to access on the HTTP server.
// +optional
Path string `json:"path,omitempty"`
// Name or number of the port to access on the container.
// Number must be in the range 1 to 65535.
// Name must be an IANA_SVC_NAME.
// +optional
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
Host string `json:"host,omitempty"`
// Scheme to use for connecting to the host.
// Defaults to HTTP.
// +optional
Scheme corev1.URIScheme `json:"scheme,omitempty"`
// Custom headers to set in the request. HTTP allows repeated headers.
// +optional
HTTPHeaders []corev1.HTTPHeader `json:"httpHeaders,omitempty"`
}

// BaseComponentProbes describes the probes for application container
type BaseComponentProbes interface {
GetLivenessProbe() *corev1.Probe
GetReadinessProbe() *corev1.Probe
GetStartupProbe() *corev1.Probe
GetLivenessProbe() *BaseComponentProbe
GetReadinessProbe() *BaseComponentProbe
GetStartupProbe() *BaseComponentProbe

GetDefaultLivenessProbe(ba BaseComponent) *corev1.Probe
GetDefaultReadinessProbe(ba BaseComponent) *corev1.Probe
GetDefaultStartupProbe(ba BaseComponent) *corev1.Probe
GetDefaultLivenessProbe(ba BaseComponent) *BaseComponentProbe
GetDefaultReadinessProbe(ba BaseComponent) *BaseComponentProbe
GetDefaultStartupProbe(ba BaseComponent) *BaseComponentProbe
}

type BaseComponentServiceAccount interface {
Expand Down
Loading