Skip to content
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
49 changes: 44 additions & 5 deletions eos/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,21 +1100,31 @@ func TestEOSVersionOnHostFallsBackToDashVersion(t *testing.T) {
}
}

func TestQDBVersionOnHostUsesEOSBuildVersion(t *testing.T) {
func TestQDBVersionOnHostUsesRaftInfoVersion(t *testing.T) {
runner := &scriptedRunner{responses: []scriptedResponse{
{out: []byte("5.4.2-20260429174732git29f83ccc8.el9\n")},
{out: []byte(`LEADER eospilot-ns-02.cern.ch:7777
----------
MYSELF eospilot-ns-02.cern.ch:7777
VERSION 5.4.2.1
STATUS LEADER
----------
NODES eospilot-ns-02.cern.ch:7777
`)},
}}
c := &Client{timeout: time.Second, runner: runner}

got, err := c.qdbVersionOnHost(context.Background(), "")
if err != nil {
t.Fatalf("qdbVersionOnHost() error: %v", err)
}
if got != "5.4.2-20260429174732git29f83ccc8" {
t.Fatalf("expected EOS build version for QDB host, got %q", got)
if got != "5.4.2.1" {
t.Fatalf("expected raft-info QDB version, got %q", got)
}
if len(runner.calls) != 1 {
t.Fatalf("expected no raft-info fallback after EOS build version, got %d commands", len(runner.calls))
t.Fatalf("expected one raft-info command, got %d commands", len(runner.calls))
}
if runner.calls[0].name != "redis-cli" || strings.Join(runner.calls[0].args, " ") != "-p 7777 raft-info" {
t.Fatalf("expected redis-cli raft-info, got %+v", runner.calls[0])
}
}

Expand Down Expand Up @@ -1574,6 +1584,35 @@ uid=all gid=all ns.qdb.followers=eospilot-ns-01.cern.ch:7777,eospilot-ns-ip700.c
}
}

func TestMGMsRaftFallbackDoesNotUseQDBVersionForMGM(t *testing.T) {
runner := &scriptedRunner{responses: []scriptedResponse{
{out: []byte("uid=all gid=all master_id=eospilot-ns-02.cern.ch:1094\n")},
{out: []byte(`LEADER eospilot-ns-02.cern.ch:7777
----------
MYSELF eospilot-ns-02.cern.ch:7777
VERSION 5.4.2.1
STATUS LEADER
----------
NODES eospilot-ns-02.cern.ch:7777
`)},
}}
c := &Client{timeout: time.Second, runner: runner}

mgms, err := c.MGMs(context.Background())
if err != nil {
t.Fatalf("MGMs() error: %v", err)
}
if len(mgms) != 1 {
t.Fatalf("expected one MGM record, got %d", len(mgms))
}
if got := mgms[0].EOSVersion; got != "" {
t.Fatalf("expected MGM version to stay empty until eos version probe, got %q", got)
}
if got := mgms[0].QDBVersion; got != "5.4.2.1" {
t.Fatalf("expected QDB version from raft-info, got %q", got)
}
}

func TestNodeStatsFromMonitoringValues(t *testing.T) {
values := parseMonitoringKeyValues([]byte(`
uid=all gid=all ns.total.files=23502173
Expand Down
19 changes: 10 additions & 9 deletions eos/fetch_mgm.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ func (c *Client) mgmsFromRaftInfo(ctx context.Context, mgmPort string) ([]MgmRec
qh, qp := splitHostPort(node)

mgms = append(mgms, MgmRecord{
Host: h,
Port: p,
QDBHost: qh,
QDBPort: qp,
Role: role,
QDBRole: role,
Status: status,
QDBStatus: status,
EOSVersion: version,
Host: h,
Port: p,
QDBHost: qh,
QDBPort: qp,
Role: role,
QDBRole: role,
Status: status,
QDBStatus: status,
// raft-info reports the QuarkDB version. The MGM version is probed
// separately with EOS commands so these columns cannot be confused.
QDBVersion: version,
})
}
Expand Down
4 changes: 0 additions & 4 deletions eos/fetch_mgm_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ func (c *Client) eosVersionOnHost(ctx context.Context, host string) (string, err
}

func (c *Client) qdbVersionOnHost(ctx context.Context, host string) (string, error) {
if version, err := c.eosVersionOnHost(ctx, host); err == nil && version != "" {
return version, nil
}

output, err := c.runCommandOnHost(ctx, host, "redis-cli", "-p", "7777", "raft-info")
if err != nil {
return "", fmt.Errorf("redis-cli raft-info: %w", err)
Expand Down
Loading