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

switch node names to machine ID #251

Merged
merged 21 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions internal/flypg/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/flypg/repmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions internal/flypg/zombie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
benwaffle marked this conversation as resolved.
Show resolved Hide resolved
if primary.Hostname != node.RepMgr.machineIdToDNS(node.MachineID) && primary.Hostname != node.PrivateIP {
sample.totalConflicts++
sample.conflictMap[primary.Hostname]++
}
Expand Down
Loading