From 0da846b940dcd03b871a027d294cabe4bbdcab53 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Tue, 8 Oct 2024 15:18:30 -0600 Subject: [PATCH 1/3] probestrategyreachable --- api/v1/cosmosfullnode_types.go | 6 ++++-- config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml | 2 ++ internal/fullnode/pod_builder.go | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/v1/cosmosfullnode_types.go b/api/v1/cosmosfullnode_types.go index 24d13e2c..ec89f6ed 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 92fde62f..745e805a 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{ From cfcd3292814c6147cdbc5645f4bbbc7964e5b946 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Tue, 8 Oct 2024 15:23:00 -0600 Subject: [PATCH 2/3] tests --- internal/fullnode/pod_builder_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/fullnode/pod_builder_test.go b/internal/fullnode/pod_builder_test.go index 8ceb7cc4..ad5c84cb 100644 --- a/internal/fullnode/pod_builder_test.go +++ b/internal/fullnode/pod_builder_test.go @@ -548,6 +548,25 @@ 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) { From f2f2003cebc039814ba3625f6e5c3e5da2f457d8 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Tue, 8 Oct 2024 15:41:45 -0600 Subject: [PATCH 3/3] lint --- internal/fullnode/pod_builder_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/fullnode/pod_builder_test.go b/internal/fullnode/pod_builder_test.go index ad5c84cb..bea97424 100644 --- a/internal/fullnode/pod_builder_test.go +++ b/internal/fullnode/pod_builder_test.go @@ -566,7 +566,6 @@ gaiad start --home /home/operator/cosmos` 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) {