Merge pull request #14805 from travisn/remove-extra-mon
mon: Do not remove extra mon in middle of failover
This commit is contained in:
2 files changed
+27
No files matched your search
@@ -1068,7 +1068,16 @@ func (c *Cluster) startDeployments(mons []*monConfig, requireAllInQuorum bool) e
|
||||
}
|
||||
|
||||
func (c *Cluster) checkForExtraMonResources(mons []*monConfig, deployments []apps.Deployment) string {
|
||||
// If there are fewer mon deployments than the desired count, no need to remove an extra.
|
||||
if len(deployments) <= c.spec.Mon.Count || len(deployments) <= len(mons) {
|
||||
logger.Debug("no extra mon deployments to remove")
|
||||
return ""
|
||||
}
|
||||
// If there are fewer mons in the list than expected, either new mons are being created for
|
||||
// a new cluster, or a mon failover is in progress and the list of mons only
|
||||
// includes the single mon that was just started
|
||||
if len(mons) < c.spec.Mon.Count {
|
||||
logger.Debug("new cluster or mon failover in progress, not checking for extra mon deployments")
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -718,6 +718,24 @@ func TestRemoveExtraMonDeployments(t *testing.T) {
|
||||
c.spec.Mon.Count = 3
|
||||
removed = c.checkForExtraMonResources(mons, deployments)
|
||||
assert.Equal(t, "", removed)
|
||||
|
||||
// Do not remove a mon when it was during failover and only a single mon is in the list, even if extra deployments exist
|
||||
mons = []*monConfig{
|
||||
{ResourceName: "rook-ceph-mon-d", DaemonName: "d"},
|
||||
}
|
||||
deployments = append(deployments, apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "rook-ceph-mon-c",
|
||||
Labels: map[string]string{"ceph_daemon_id": "c"},
|
||||
}})
|
||||
deployments = append(deployments, apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "rook-ceph-mon-d",
|
||||
Labels: map[string]string{"ceph_daemon_id": "d"},
|
||||
}})
|
||||
c.spec.Mon.Count = 3
|
||||
removed = c.checkForExtraMonResources(mons, deployments)
|
||||
assert.Equal(t, "", removed)
|
||||
}
|
||||
|
||||
func TestStretchMonVolumeClaimTemplate(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user