Merge pull request #14983 from rook/mergify/bp/release-1.15/pr-14981

operator: monitors should always be allowed to failover (backport #14981)
This commit is contained in:
mergify[bot] authored and GitHub committed 2024-11-08 17:03:19 +00:00
commit 01d8e5ea32
2 files changed
-43

No files matched your search

-19
View File
@@ -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")
@@ -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)