From 53284918803d3789236a5d075fffbb2a39b28ff8 Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Tue, 19 Apr 2022 15:48:11 +0530 Subject: [PATCH] core: make code changes to support latest cntrl runtime making necessary code changes to support controller runtime version. Signed-off-by: subhamkrai (cherry picked from commit bf7daccf60d72c388db0e9f655c80f3f3980d501) --- pkg/operator/ceph/config/probes.go | 2 +- pkg/operator/ceph/config/probes_test.go | 22 +++++++++--------- pkg/operator/ceph/controller/spec.go | 2 +- pkg/operator/ceph/controller/spec_test.go | 2 +- pkg/operator/ceph/object/spec.go | 4 ++-- pkg/operator/ceph/object/spec_test.go | 28 +++++++++++------------ 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pkg/operator/ceph/config/probes.go b/pkg/operator/ceph/config/probes.go index b31a6a7ff..c9660ffe7 100644 --- a/pkg/operator/ceph/config/probes.go +++ b/pkg/operator/ceph/config/probes.go @@ -72,7 +72,7 @@ func GetProbeWithDefaults(desiredProbe, currentProbe *v1.Probe) *v1.Probe { // // Let's always force the default handler, there is no reason to change it anyway since the underlying content is generated based on the daemon's name // so we can not make it generic via the spec - newProbe.Handler = currentProbe.Handler + newProbe.ProbeHandler = currentProbe.ProbeHandler // If the user has not specified thresholds and timeouts, set them to the same values as // in the default liveness probe created by Rook. diff --git a/pkg/operator/ceph/config/probes_test.go b/pkg/operator/ceph/config/probes_test.go index 8879d745c..84656811e 100644 --- a/pkg/operator/ceph/config/probes_test.go +++ b/pkg/operator/ceph/config/probes_test.go @@ -56,7 +56,7 @@ func TestConfigureLivenessProbe(t *testing.T) { func configLivenessProbeHelper(t *testing.T, keyType cephv1.KeyType, livenessProbes map[cephv1.KeyType]*cephv1.ProbeSpec) { p := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/", Port: intstr.FromInt(8080), @@ -77,7 +77,7 @@ func configLivenessProbeHelper(t *testing.T, keyType cephv1.KeyType, livenessPro func integrationLivenessProbeCheck(t *testing.T, keyType cephv1.KeyType, livenessProbes map[cephv1.KeyType]*cephv1.ProbeSpec) { t.Run("integration check: configured probes should override values", func(t *testing.T) { defaultProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/", Port: intstr.FromInt(8443), @@ -85,7 +85,7 @@ func integrationLivenessProbeCheck(t *testing.T, keyType cephv1.KeyType, livenes }, } userProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/custom/path", Port: intstr.FromInt(8080), @@ -108,7 +108,7 @@ func integrationLivenessProbeCheck(t *testing.T, keyType cephv1.KeyType, livenes // the resultant container's startup probe should have been overridden, but the handler // should always be the rook-given default expectedProbe := *userProbe - expectedProbe.Handler = defaultProbe.Handler + expectedProbe.ProbeHandler = defaultProbe.ProbeHandler assert.Equal(t, &expectedProbe, got.StartupProbe) }) } @@ -140,7 +140,7 @@ func TestConfigureStartupProbe(t *testing.T) { func configStartupProbeHelper(t *testing.T, keyType cephv1.KeyType, startupProbes map[cephv1.KeyType]*cephv1.ProbeSpec) { p := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/", Port: intstr.FromInt(8080), @@ -160,7 +160,7 @@ func configStartupProbeHelper(t *testing.T, keyType cephv1.KeyType, startupProbe func integrationStartupProbeCheck(t *testing.T, keyType cephv1.KeyType, startupProbes map[cephv1.KeyType]*cephv1.ProbeSpec) { t.Run("integration check: configured probes should override values", func(t *testing.T) { defaultProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/", Port: intstr.FromInt(8443), @@ -168,7 +168,7 @@ func integrationStartupProbeCheck(t *testing.T, keyType cephv1.KeyType, startupP }, } userProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/custom/path", Port: intstr.FromInt(8080), @@ -191,7 +191,7 @@ func integrationStartupProbeCheck(t *testing.T, keyType cephv1.KeyType, startupP // the resultant container's startup probe should have been overridden, but the handler // should always be the rook-given default expectedProbe := *userProbe - expectedProbe.Handler = defaultProbe.Handler + expectedProbe.ProbeHandler = defaultProbe.ProbeHandler assert.Equal(t, &expectedProbe, got.StartupProbe) }) } @@ -199,7 +199,7 @@ func integrationStartupProbeCheck(t *testing.T, keyType cephv1.KeyType, startupP func TestGetProbeWithDefaults(t *testing.T) { t.Run("using default probe", func(t *testing.T) { currentProb := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ Exec: &v1.ExecAction{ // Example: Command: []string{ @@ -221,7 +221,7 @@ func TestGetProbeWithDefaults(t *testing.T) { t.Run("overriding default probes", func(t *testing.T) { currentProb := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ Exec: &v1.ExecAction{ // Example: Command: []string{ @@ -237,7 +237,7 @@ func TestGetProbeWithDefaults(t *testing.T) { } desiredProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ Exec: &v1.ExecAction{ // Example: Command: []string{ diff --git a/pkg/operator/ceph/controller/spec.go b/pkg/operator/ceph/controller/spec.go index d7e185f07..9bc268671 100644 --- a/pkg/operator/ceph/controller/spec.go +++ b/pkg/operator/ceph/controller/spec.go @@ -561,7 +561,7 @@ func GenerateLivenessProbeExecDaemon(daemonType, daemonID string) *v1.Probe { confDaemon := getDaemonConfig(daemonType, daemonID) return &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ Exec: &v1.ExecAction{ // Run with env -i to clean env variables in the exec context // This avoids conflict with the CEPH_ARGS env diff --git a/pkg/operator/ceph/controller/spec_test.go b/pkg/operator/ceph/controller/spec_test.go index 86069e76a..0dee5c7f7 100644 --- a/pkg/operator/ceph/controller/spec_test.go +++ b/pkg/operator/ceph/controller/spec_test.go @@ -157,7 +157,7 @@ func TestGenerateLivenessProbeExecDaemon(t *testing.T) { "ceph --admin-daemon /run/ceph/ceph-osd.0.asok status", } - assert.Equal(t, expectedCommand, probe.Handler.Exec.Command) + assert.Equal(t, expectedCommand, probe.ProbeHandler.Exec.Command) assert.Equal(t, livenessProbeInitialDelaySeconds, probe.InitialDelaySeconds) // test with a mon so the delay should be 10 diff --git a/pkg/operator/ceph/object/spec.go b/pkg/operator/ceph/object/spec.go index 938c3ba3f..20275001a 100644 --- a/pkg/operator/ceph/object/spec.go +++ b/pkg/operator/ceph/object/spec.go @@ -376,7 +376,7 @@ func configureReadinessProbe(container *v1.Container, healthCheck cephv1.BucketH func (c *clusterConfig) defaultLivenessProbe() *v1.Probe { return &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ TCPSocket: &v1.TCPSocketAction{ Port: c.generateProbePort(), }, @@ -387,7 +387,7 @@ func (c *clusterConfig) defaultLivenessProbe() *v1.Probe { func (c *clusterConfig) defaultReadinessProbe() *v1.Probe { return &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: readinessProbePath, Port: c.generateProbePort(), diff --git a/pkg/operator/ceph/object/spec_test.go b/pkg/operator/ceph/object/spec_test.go index 308e1e95a..15ec1bca1 100644 --- a/pkg/operator/ceph/object/spec_test.go +++ b/pkg/operator/ceph/object/spec_test.go @@ -308,7 +308,7 @@ func TestDefaultLivenessProbe(t *testing.T) { } desiredProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ TCPSocket: &v1.TCPSocketAction{ Port: intstr.FromInt(8080), }, @@ -324,7 +324,7 @@ func TestDefaultLivenessProbe(t *testing.T) { c.store.Spec.Gateway.SecurePort = 0 c.clusterSpec.Network.HostNetwork = true p = c.defaultLivenessProbe() - desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(123) + desiredProbe.ProbeHandler.TCPSocket.Port = intstr.FromInt(123) assert.Equal(t, desiredProbe, p) // SSL - HostNetwork is enabled @@ -332,7 +332,7 @@ func TestDefaultLivenessProbe(t *testing.T) { c.store.Spec.Gateway.SecurePort = 321 c.store.Spec.Gateway.SSLCertificateRef = "foo" p = c.defaultLivenessProbe() - desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(321) + desiredProbe.ProbeHandler.TCPSocket.Port = intstr.FromInt(321) assert.Equal(t, desiredProbe, p) // Both Non-SSL and SSL are enabled @@ -340,7 +340,7 @@ func TestDefaultLivenessProbe(t *testing.T) { c.store.Spec.Gateway.Port = 123 c.store.Spec.Gateway.SecurePort = 321 p = c.defaultLivenessProbe() - desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(123) + desiredProbe.ProbeHandler.TCPSocket.Port = intstr.FromInt(123) assert.Equal(t, desiredProbe, p) } @@ -356,7 +356,7 @@ func TestDefaultStartupProbe(t *testing.T) { } desiredProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ TCPSocket: &v1.TCPSocketAction{ Port: intstr.FromInt(8080), }, @@ -374,7 +374,7 @@ func TestDefaultStartupProbe(t *testing.T) { c.store.Spec.Gateway.SecurePort = 0 c.clusterSpec.Network.HostNetwork = true p = c.defaultStartupProbe() - desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(123) + desiredProbe.ProbeHandler.TCPSocket.Port = intstr.FromInt(123) assert.Equal(t, desiredProbe, p) // SSL - HostNetwork is enabled @@ -382,7 +382,7 @@ func TestDefaultStartupProbe(t *testing.T) { c.store.Spec.Gateway.SecurePort = 321 c.store.Spec.Gateway.SSLCertificateRef = "foo" p = c.defaultStartupProbe() - desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(321) + desiredProbe.ProbeHandler.TCPSocket.Port = intstr.FromInt(321) assert.Equal(t, desiredProbe, p) // Both Non-SSL and SSL are enabled @@ -390,7 +390,7 @@ func TestDefaultStartupProbe(t *testing.T) { c.store.Spec.Gateway.Port = 123 c.store.Spec.Gateway.SecurePort = 321 p = c.defaultStartupProbe() - desiredProbe.Handler.TCPSocket.Port = intstr.FromInt(123) + desiredProbe.ProbeHandler.TCPSocket.Port = intstr.FromInt(123) assert.Equal(t, desiredProbe, p) } @@ -406,7 +406,7 @@ func TestDefaultReadinessProbe(t *testing.T) { } desiredProbe := &v1.Probe{ - Handler: v1.Handler{ + ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: readinessProbePath, Port: intstr.FromInt(8080), @@ -424,7 +424,7 @@ func TestDefaultReadinessProbe(t *testing.T) { c.store.Spec.Gateway.SecurePort = 0 c.clusterSpec.Network.HostNetwork = true p = c.defaultReadinessProbe() - desiredProbe.Handler.HTTPGet.Port = intstr.FromInt(123) + desiredProbe.ProbeHandler.HTTPGet.Port = intstr.FromInt(123) assert.Equal(t, desiredProbe, p) // SSL - HostNetwork is enabled @@ -432,8 +432,8 @@ func TestDefaultReadinessProbe(t *testing.T) { c.store.Spec.Gateway.SecurePort = 321 c.store.Spec.Gateway.SSLCertificateRef = "foo" p = c.defaultReadinessProbe() - desiredProbe.Handler.HTTPGet.Port = intstr.FromInt(321) - desiredProbe.Handler.HTTPGet.Scheme = v1.URISchemeHTTPS + desiredProbe.ProbeHandler.HTTPGet.Port = intstr.FromInt(321) + desiredProbe.ProbeHandler.HTTPGet.Scheme = v1.URISchemeHTTPS assert.Equal(t, desiredProbe, p) // Both Non-SSL and SSL are enabled @@ -441,8 +441,8 @@ func TestDefaultReadinessProbe(t *testing.T) { c.store.Spec.Gateway.Port = 123 c.store.Spec.Gateway.SecurePort = 321 p = c.defaultReadinessProbe() - desiredProbe.Handler.HTTPGet.Port = intstr.FromInt(123) - desiredProbe.Handler.HTTPGet.Scheme = v1.URISchemeHTTP + desiredProbe.ProbeHandler.HTTPGet.Port = intstr.FromInt(123) + desiredProbe.ProbeHandler.HTTPGet.Scheme = v1.URISchemeHTTP assert.Equal(t, desiredProbe, p) }