Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2315624: Fix mds liveness probe and mon failover #746

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/operator/ceph/cluster/mon/mon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}

Expand Down
18 changes: 18 additions & 0 deletions pkg/operator/ceph/cluster/mon/mon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/operator/ceph/file/mds/livenessprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package mds
import (
"bytes"
_ "embed"
"fmt"
"html/template"

"github.com/pkg/errors"
Expand Down Expand Up @@ -38,6 +37,7 @@ type mdsLivenessProbeConfig struct {
MdsId string
FilesystemName string
Keyring string
CmdTimeout int32
}

func renderProbe(mdsLivenessProbeConfigValue mdsLivenessProbeConfig) (string, error) {
Expand All @@ -64,6 +64,7 @@ func generateMDSLivenessProbeExecDaemon(daemonID, filesystemName, keyring string
MdsId: daemonID,
FilesystemName: filesystemName,
Keyring: keyring,
CmdTimeout: mdsCmdTimeout,
}

mdsLivenessProbeCmd, err := renderProbe(mdsLivenessProbeConfigValue)
Expand All @@ -75,8 +76,6 @@ func generateMDSLivenessProbeExecDaemon(daemonID, filesystemName, keyring string
ProbeHandler: v1.ProbeHandler{
Exec: &v1.ExecAction{
Command: []string{
"timeout",
fmt.Sprintf("%d", mdsCmdTimeout),
"sh",
"-c",
mdsLivenessProbeCmd,
Expand Down
3 changes: 2 additions & 1 deletion pkg/operator/ceph/file/mds/livenessprobe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
MDS_ID="{{ .MdsId }}"
FILESYSTEM_NAME="{{ .FilesystemName }}"
KEYRING="{{ .Keyring }}"
CMD_TIMEOUT="{{ .CmdTimeout }}"

outp="$(ceph fs dump --mon-host="$ROOK_CEPH_MON_HOST" --mon-initial-members="$ROOK_CEPH_MON_INITIAL_MEMBERS" --keyring "$KEYRING" --format json)"
outp="$(ceph fs dump --mon-host="$ROOK_CEPH_MON_HOST" --mon-initial-members="$ROOK_CEPH_MON_INITIAL_MEMBERS" --keyring "$KEYRING" --connect-timeout="$CMD_TIMEOUT" --format json)"
rc=$?
if [ $rc -ne 0 ]; then
echo "ceph MDS dump check failed with the following output:"
Expand Down
Loading