From 8db49fb86523a3c062aabe7f7d14aa50903e654b Mon Sep 17 00:00:00 2001 From: Ben Iofel Date: Tue, 6 Aug 2024 19:11:02 -0400 Subject: [PATCH] missed a few --- internal/flypg/node.go | 4 ++-- internal/flypg/repmgr.go | 2 +- internal/flypg/zombie.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/flypg/node.go b/internal/flypg/node.go index f2ae0be..579b1d6 100644 --- a/internal/flypg/node.go +++ b/internal/flypg/node.go @@ -297,10 +297,10 @@ func (n *Node) PostInit(ctx context.Context) error { } // This should never happen - if primary != n.PrivateIP { + if primary != n.RepMgr.machineIdToDNS(n.MachineID) { return fmt.Errorf("resolved primary '%s' does not match ourself '%s'. this should not happen", primary, - n.PrivateIP, + n.RepMgr.machineIdToDNS(n.MachineID), ) } diff --git a/internal/flypg/repmgr.go b/internal/flypg/repmgr.go index a79b41d..cc10d6d 100644 --- a/internal/flypg/repmgr.go +++ b/internal/flypg/repmgr.go @@ -329,7 +329,7 @@ func (r *RepMgr) regenReplicationConf(ctx context.Context) error { // TODO: do we need -c? if _, err := utils.RunCmd(ctx, "postgres", "repmgr", "--replication-conf-only", - "-h", r.PrivateIP, + "-h", "", "-p", fmt.Sprint(r.Port), "-d", r.DatabaseName, "-U", r.Credentials.Username, diff --git a/internal/flypg/zombie.go b/internal/flypg/zombie.go index ca3a85d..6380338 100644 --- a/internal/flypg/zombie.go +++ b/internal/flypg/zombie.go @@ -84,7 +84,7 @@ type DNASample struct { func TakeDNASample(ctx context.Context, node *Node, standbys []Member) (*DNASample, error) { sample := &DNASample{ - hostname: node.PrivateIP, + hostname: node.RepMgr.machineIdToDNS(node.MachineID), totalMembers: len(standbys) + 1, totalActive: 1, totalInactive: 0, @@ -117,7 +117,8 @@ func TakeDNASample(ctx context.Context, node *Node, standbys []Member) (*DNASamp sample.totalActive++ // Record conflict when primary doesn't match. - if primary.Hostname != node.MachineID && primary.Hostname != node.PrivateIP { + // We're checking PrivateIP here for backwards compatibility + if primary.Hostname != node.RepMgr.machineIdToDNS(node.MachineID) && primary.Hostname != node.PrivateIP { sample.totalConflicts++ sample.conflictMap[primary.Hostname]++ }