Skip to content

Commit

Permalink
feat: ability to disable in-sync healthcheck (#439)
Browse files Browse the repository at this point in the history
* probestrategyreachable

* tests

* lint
  • Loading branch information
agouin authored Oct 8, 2024
1 parent a2e42d5 commit 467e03e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
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

0 comments on commit 467e03e

Please sign in to comment.