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

feat: ability to disable in-sync healthcheck #439

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,16 @@ type PodSpec struct {
type FullNodeProbeStrategy string

const (
FullNodeProbeStrategyNone FullNodeProbeStrategy = "None"
FullNodeProbeStrategyNone FullNodeProbeStrategy = "None"
FullNodeProbeStrategyReachable FullNodeProbeStrategy = "Reachable"
FullNodeProbeStrategyInSync FullNodeProbeStrategy = "InSync"
)

// FullNodeProbesSpec configures probes for created pods
type FullNodeProbesSpec struct {
// Strategy controls the default probes added by the controller.
// None = Do not add any probes. May be necessary for Sentries using a remote signer.
// +kubebuilder:validation:Enum:=None
// +kubebuilder:validation:Enum:=None;Reachable;InSync
// +optional
Strategy FullNodeProbeStrategy `json:"strategy"`
}
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3931,6 +3931,8 @@ spec:
None = Do not add any probes. May be necessary for Sentries using a remote signer.
enum:
- None
- Reachable
- InSync
type: string
type: object
resources:
Expand Down
4 changes: 4 additions & 0 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func podReadinessProbes(crd *cosmosv1.CosmosFullNode) []*corev1.Probe {
FailureThreshold: 5,
}

if crd.Spec.PodTemplate.Probes.Strategy == cosmosv1.FullNodeProbeStrategyReachable {
return []*corev1.Probe{mainProbe, nil}
}

sidecarProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down
18 changes: 18 additions & 0 deletions internal/fullnode/pod_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,24 @@ gaiad start --home /home/operator/cosmos`
sidecar := pod.Spec.Containers[1]
require.Equal(t, "healthcheck", sidecar.Name)
require.Nil(t, sidecar.ReadinessProbe)

crd.Spec.PodTemplate.Probes = cosmosv1.FullNodeProbesSpec{Strategy: cosmosv1.FullNodeProbeStrategyReachable}

builder = NewPodBuilder(&crd)
pod, err = builder.WithOrdinal(1).Build()
require.NoError(t, err)

require.NotNilf(t, pod.Spec.Containers[0].ReadinessProbe, "container 0")
require.Nilf(t, pod.Spec.Containers[1].ReadinessProbe, "container 1")

crd.Spec.PodTemplate.Probes = cosmosv1.FullNodeProbesSpec{Strategy: cosmosv1.FullNodeProbeStrategyInSync}

builder = NewPodBuilder(&crd)
pod, err = builder.WithOrdinal(1).Build()
require.NoError(t, err)

require.NotNilf(t, pod.Spec.Containers[0].ReadinessProbe, "container 0")
require.NotNilf(t, pod.Spec.Containers[1].ReadinessProbe, "container 1")
})

t.Run("strategic merge fields", func(t *testing.T) {
Expand Down
Loading