From cdf692d2275752a23a83dbefcc59fda6f7c6c8c8 Mon Sep 17 00:00:00 2001 From: Grant Fleming Date: Fri, 8 Nov 2024 16:42:09 +0100 Subject: [PATCH] operator: monitors should always be allowed to failover Previously arbiter monitors were allowed to failover in supported versions of Ceph. This behaviour regressed. Since all supported versions of Ceph now support this, we no longer need to check this at all. Signed-off-by: Grant Fleming --- pkg/operator/ceph/cluster/mon/health.go | 19 ---------------- pkg/operator/ceph/cluster/mon/health_test.go | 24 -------------------- 2 files changed, 43 deletions(-) diff --git a/pkg/operator/ceph/cluster/mon/health.go b/pkg/operator/ceph/cluster/mon/health.go index a8fe149fe..050d88f43 100644 --- a/pkg/operator/ceph/cluster/mon/health.go +++ b/pkg/operator/ceph/cluster/mon/health.go @@ -518,11 +518,6 @@ func (c *Cluster) failMon(monCount, desiredMonCount int, name string) bool { return true } - if err := c.allowFailover(name); err != nil { - logger.Warningf("aborting mon %q failover. %v", name, err) - return false - } - // prevent any voluntary mon drain while failing over if err := c.blockMonDrain(types.NamespacedName{Name: monPDBName, Namespace: c.Namespace}); err != nil { logger.Errorf("failed to block mon drain. %v", err) @@ -540,20 +535,6 @@ func (c *Cluster) failMon(monCount, desiredMonCount int, name string) bool { return true } -func (c *Cluster) allowFailover(name string) error { - if !c.spec.IsStretchCluster() { - // always failover if not a stretch cluster - return nil - } - if name != c.arbiterMon { - // failover if it's a non-arbiter - return nil - } - - // Ceph does not support updating the arbiter mon in older versions - return errors.Errorf("refusing to failover arbiter mon %q on a stretched cluster", name) -} - func (c *Cluster) removeOrphanMonResources() { if c.spec.Mon.VolumeClaimTemplate == nil { logger.Debug("skipping check for orphaned mon pvcs since using the host path") diff --git a/pkg/operator/ceph/cluster/mon/health_test.go b/pkg/operator/ceph/cluster/mon/health_test.go index 9ae4cbe3d..90a778dbc 100644 --- a/pkg/operator/ceph/cluster/mon/health_test.go +++ b/pkg/operator/ceph/cluster/mon/health_test.go @@ -251,30 +251,6 @@ func TestTrackMonsOutOfQuorum(t *testing.T) { assert.Equal(t, "", cm.Data[opcontroller.OutOfQuorumKey]) } -func TestSkipMonFailover(t *testing.T) { - c := New(context.TODO(), &clusterd.Context{}, "ns", cephv1.ClusterSpec{}, nil) - c.ClusterInfo = clienttest.CreateTestClusterInfo(1) - monName := "arb" - - t.Run("don't skip failover for non-stretch", func(t *testing.T) { - assert.NoError(t, c.allowFailover(monName)) - }) - - t.Run("don't skip failover for non-arbiter", func(t *testing.T) { - c.spec.Mon.Count = 5 - c.spec.Mon.StretchCluster = &cephv1.StretchClusterSpec{ - Zones: []cephv1.MonZoneSpec{ - {Name: "a"}, - {Name: "b"}, - {Name: "c", Arbiter: true}, - }, - } - - assert.NoError(t, c.allowFailover(monName)) - }) - -} - func TestEvictMonOnSameNode(t *testing.T) { ctx := context.TODO() clientset := test.New(t, 1)