diff --git a/api/v1/cosmosfullnode_types.go b/api/v1/cosmosfullnode_types.go index 54a2c34d..68a5b7e3 100644 --- a/api/v1/cosmosfullnode_types.go +++ b/api/v1/cosmosfullnode_types.go @@ -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"` } diff --git a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml index 33bc8869..df0f8b39 100644 --- a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml +++ b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml @@ -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: diff --git a/internal/fullnode/pod_builder.go b/internal/fullnode/pod_builder.go index f2a08e6d..92ba5c2a 100644 --- a/internal/fullnode/pod_builder.go +++ b/internal/fullnode/pod_builder.go @@ -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{ diff --git a/internal/fullnode/pod_builder_test.go b/internal/fullnode/pod_builder_test.go index 8ceb7cc4..bea97424 100644 --- a/internal/fullnode/pod_builder_test.go +++ b/internal/fullnode/pod_builder_test.go @@ -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) {