mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-12 14:07:28 +00:00
fix(sensor-proxy): relax pvecm status parsing to support decimal node IDs
Fixes an issue where pvecm status output using decimal node IDs (e.g. '1' instead of '0x1') caused node discovery to fail. Added test case for this format.
This commit is contained in:
parent
dedce8796b
commit
53836ea9b0
2 changed files with 10 additions and 12 deletions
|
|
@ -740,24 +740,14 @@ func parseClusterNodes(output string) ([]string, error) {
|
|||
var nodes []string
|
||||
lines := strings.Split(output, "\n")
|
||||
for _, line := range lines {
|
||||
// Look for lines with hex ID and IP address
|
||||
if !strings.Contains(line, "0x") {
|
||||
continue
|
||||
}
|
||||
|
||||
fields := strings.Fields(line)
|
||||
// Need at least 3 fields: hex_id votes ip [optional:(local)]
|
||||
if len(fields) < 3 {
|
||||
// Need at least 2 fields to be a valid node line (id + ip/name)
|
||||
if len(fields) < 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
// Iterate through fields to find the IP address
|
||||
for _, field := range fields {
|
||||
// Skip hex ID
|
||||
if strings.HasPrefix(field, "0x") {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if it's a valid IP
|
||||
if ip := net.ParseIP(field); ip != nil {
|
||||
nodes = append(nodes, field)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ func TestParseClusterNodes(t *testing.T) {
|
|||
output: "some random text",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "numeric node id format",
|
||||
output: `Membership information
|
||||
----------------------
|
||||
Nodeid Votes Name
|
||||
1 10.0.0.5 2`,
|
||||
want: []string{"10.0.0.5"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue