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 <sapillai@redhat.com>
(cherry picked from commit a4866b4b06)
This commit is contained in:
1 parent
f9cdbbd06a
commit
b0cb722638
2 files changed
+12
-4
No files matched your search
@@ -43,7 +43,7 @@ func (c *Cluster) reconcileMonPDB() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
op, err := c.createOrUpdateMonPDB(1)
|
||||
op, err := c.createOrUpdateMonPDB(c.getMaxUnavailableMonPodCount())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to reconcile mon pdb on op %q", op)
|
||||
}
|
||||
@@ -108,10 +108,18 @@ func (c *Cluster) allowMonDrain(request types.NamespacedName) error {
|
||||
return nil
|
||||
}
|
||||
logger.Info("allow voluntary mon drain after failover")
|
||||
// change MaxUnavailable mon PDB to 1
|
||||
_, err := c.createOrUpdateMonPDB(1)
|
||||
_, err := c.createOrUpdateMonPDB(c.getMaxUnavailableMonPodCount())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update MaxUnavailable for mon PDB %q", request.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) getMaxUnavailableMonPodCount() int32 {
|
||||
if c.spec.Mon.Count >= 5 {
|
||||
logger.Debug("setting the mon pdb max unavailable count to 2 in case there are 5 or more mons")
|
||||
return 2
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestReconcileMonPDB(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedMaxUnAvailable: 1,
|
||||
expectedMaxUnAvailable: 2,
|
||||
errorExpected: false,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user