Skip to content

Commit 0ae0819

Browse files
committed
mon: set mon pdb max unavailable as 2 in case of 5 or more mons
If the spec.mon.count is 5 or more, then create mon pdbs with maxUnavailable count as 2. We can afford to have more than 1 mons down while draining the nodes in this case. Signed-off-by: sp98 <[email protected]> (cherry picked from commit a4866b4)
1 parent 2320def commit 0ae0819

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/operator/ceph/cluster/mon/drain.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c *Cluster) reconcileMonPDB() error {
4343
return nil
4444
}
4545

46-
op, err := c.createOrUpdateMonPDB(1)
46+
op, err := c.createOrUpdateMonPDB(c.getMaxUnavailableMonPodCount())
4747
if err != nil {
4848
return errors.Wrapf(err, "failed to reconcile mon pdb on op %q", op)
4949
}
@@ -108,10 +108,18 @@ func (c *Cluster) allowMonDrain(request types.NamespacedName) error {
108108
return nil
109109
}
110110
logger.Info("allow voluntary mon drain after failover")
111-
// change MaxUnavailable mon PDB to 1
112-
_, err := c.createOrUpdateMonPDB(1)
111+
_, err := c.createOrUpdateMonPDB(c.getMaxUnavailableMonPodCount())
113112
if err != nil {
114113
return errors.Wrapf(err, "failed to update MaxUnavailable for mon PDB %q", request.Name)
115114
}
116115
return nil
117116
}
117+
118+
func (c *Cluster) getMaxUnavailableMonPodCount() int32 {
119+
if c.spec.Mon.Count >= 5 {
120+
logger.Debug("setting the mon pdb max unavailable count to 2 in case there are 5 or more mons")
121+
return 2
122+
}
123+
124+
return 1
125+
}

pkg/operator/ceph/cluster/mon/drain_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func TestReconcileMonPDB(t *testing.T) {
102102
},
103103
},
104104
},
105-
expectedMaxUnAvailable: 1,
105+
expectedMaxUnAvailable: 2,
106106
errorExpected: false,
107107
},
108108
}

0 commit comments

Comments
 (0)