Skip to content

Commit bf588be

Browse files
committed
Forgot to add this
1 parent 4bddb85 commit bf588be

File tree

1 file changed

+7
-39
lines changed

1 file changed

+7
-39
lines changed

internal/flypg/node.go

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -342,49 +342,17 @@ func (n *Node) PostInit(ctx context.Context) error {
342342
}
343343
}
344344

345-
totalMembers := len(standbys) + 1
346-
totalActive := 1
347-
totalInactive := 0
348-
totalConflicts := 0
349-
350-
conflictMap := map[string]int{}
351-
352-
for _, standby := range standbys {
353-
// Check for connectivity
354-
mConn, err := repmgr.NewRemoteConnection(ctx, standby.Hostname)
355-
if err != nil {
356-
fmt.Printf("failed to connect to %s", standby.Hostname)
357-
totalInactive++
358-
continue
359-
}
360-
defer mConn.Close(ctx)
361-
362-
// Verify the primary
363-
primary, err := repmgr.PrimaryMember(ctx, mConn)
364-
if err != nil {
365-
fmt.Printf("failed to resolve primary from standby %s", standby.Hostname)
366-
totalInactive++
367-
continue
368-
}
369-
370-
totalActive++
371-
372-
// Record conflict when primary doesn't match.
373-
if primary.Hostname != n.PrivateIP {
374-
totalConflicts++
375-
conflictMap[primary.Hostname]++
376-
}
345+
// Collect sample data from registered standbys
346+
sample, err := ZombieDNASample(ctx, n, standbys)
347+
if err != nil {
348+
return fmt.Errorf("failed to resolve cluster metrics: %s", err)
377349
}
378350

379-
primary, err := ZombieDiagnosis(n.PrivateIP, totalMembers, totalInactive, totalActive, conflictMap)
351+
printDNASample(sample)
352+
353+
primary, err := ZombieDiagnosis(sample)
380354
if errors.Is(err, ErrZombieDiagnosisUndecided) {
381355
fmt.Println("Unable to confirm that we are the true primary!")
382-
fmt.Printf("Registered members: %d, Active member(s): %d, Inactive member(s): %d, Conflicts detected: %d\n",
383-
totalMembers,
384-
totalActive,
385-
totalInactive,
386-
totalConflicts,
387-
)
388356

389357
fmt.Println("Writing zombie.lock file.")
390358
if err := writeZombieLock(""); err != nil {

0 commit comments

Comments
 (0)