Skip to content

Commit

Permalink
fix: agent ip should use externalIP over internalIP
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Nov 30, 2023
1 parent 8a99ce0 commit e5c1539
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/agent/remote/agent_registry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ func (c *AgentRegistryConnect) patchAgentInfo(ctx context.Context) error {
for _, n := range clusterinfo.FromContext(ctx).Nodes {
if n.Role == "control-plane" {
if e.Hostname() != "127.0.0.1" {
if internalIP := n.InternalIP; internalIP != "" {
if externalIP := n.ExternalIP; externalIP != "" {
port := e.Port()
if port == "" {
port = "80"
}
e.Host = fmt.Sprintf("%s:%s", internalIP, port)
e.Host = fmt.Sprintf("%s:%s", externalIP, port)
} else {
if internalIP := n.InternalIP; internalIP != "" {
port := e.Port()
if port == "" {
port = "80"
}
e.Host = fmt.Sprintf("%s:%s", internalIP, port)
}
}
}

Expand Down

0 comments on commit e5c1539

Please sign in to comment.