From 1332d7c041e9f97f925ac9eb53297022f2c4ad2b Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Thu, 6 Jan 2022 06:14:12 +0000 Subject: [PATCH] rgw: fix startup probe It's better to set the same handler to startupProbe as livenessProbe. Otherwise, we might hit the following problem. https://github.com/rook/rook/issues/6304 Signed-off-by: Satoru Takeuchi (cherry picked from commit af88b50fc75f2cd4cda93a5361137bb1d515aa65) --- pkg/operator/ceph/object/spec.go | 16 +++------ pkg/operator/ceph/object/spec_test.go | 50 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/pkg/operator/ceph/object/spec.go b/pkg/operator/ceph/object/spec.go index 25656b497a4a..dc6251ea9b2a 100644 --- a/pkg/operator/ceph/object/spec.go +++ b/pkg/operator/ceph/object/spec.go @@ -420,18 +420,10 @@ func (c *clusterConfig) defaultReadinessProbe() *v1.Probe { } func (c *clusterConfig) defaultStartupProbe() *v1.Probe { - return &v1.Probe{ - Handler: v1.Handler{ - HTTPGet: &v1.HTTPGetAction{ - Path: readinessProbePath, - Port: c.generateProbePort(), - Scheme: c.generateReadinessProbeScheme(), - }, - }, - InitialDelaySeconds: 10, - PeriodSeconds: 10, - FailureThreshold: 18, - } + probe := c.defaultLivenessProbe() + probe.PeriodSeconds = 10 + probe.FailureThreshold = 18 + return probe } func (c *clusterConfig) generateReadinessProbeScheme() v1.URIScheme { diff --git a/pkg/operator/ceph/object/spec_test.go b/pkg/operator/ceph/object/spec_test.go index 28ea5c97047e..18ba1ef6509e 100644 --- a/pkg/operator/ceph/object/spec_test.go +++ b/pkg/operator/ceph/object/spec_test.go @@ -333,6 +333,56 @@ func TestDefaultLivenessProbe(t *testing.T) { assert.Equal(t, desiredProbe, p) } +func TestDefaultStartupProbe(t *testing.T) { + store := simpleStore() + c := &clusterConfig{ + store: store, + clusterSpec: &cephv1.ClusterSpec{ + Network: cephv1.NetworkSpec{ + HostNetwork: false, + }, + }, + } + + desiredProbe := &v1.Probe{ + Handler: v1.Handler{ + TCPSocket: &v1.TCPSocketAction{ + Port: intstr.FromInt(8080), + }, + }, + InitialDelaySeconds: 10, + PeriodSeconds: 10, + FailureThreshold: 18, + } + // No SSL - HostNetwork is disabled - using internal port + p := c.defaultStartupProbe() + assert.Equal(t, desiredProbe, p) + + // No SSL - HostNetwork is enabled + c.store.Spec.Gateway.Port = 123 + c.store.Spec.Gateway.SecurePort = 0 + c.clusterSpec.Network.HostNetwork = true + p = c.defaultStartupProbe() + desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(123) + assert.Equal(t, desiredProbe, p) + + // SSL - HostNetwork is enabled + c.store.Spec.Gateway.Port = 0 + c.store.Spec.Gateway.SecurePort = 321 + c.store.Spec.Gateway.SSLCertificateRef = "foo" + p = c.defaultStartupProbe() + desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(321) + assert.Equal(t, desiredProbe, p) + + // Both Non-SSL and SSL are enabled + // livenessProbe just on Non-SSL + c.store.Spec.Gateway.Port = 123 + c.store.Spec.Gateway.SecurePort = 321 + p = c.defaultStartupProbe() + desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(123) + assert.Equal(t, desiredProbe, p) +} + func TestDefaultReadinessProbe(t *testing.T) { store := simpleStore() c := &clusterConfig{