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

Don't add duplicate Hostname address #36231

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions pkg/kubelet/kubelet_node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,22 @@ func (kl *Kubelet) setNodeAddress(node *api.Node) error {
}
return fmt.Errorf("failed to get node address from cloud provider that matches ip: %v", kl.nodeIP)
}
hostnameAddress := api.NodeAddress{Type: api.NodeHostName, Address: kl.GetHostname()}
node.Status.Addresses = append(nodeAddresses, hostnameAddress)

// Only add a NodeHostName address if the cloudprovider did not specify one
// (we assume the cloudprovider knows best)
var addressNodeHostName *api.NodeAddress
for i := range nodeAddresses {
if nodeAddresses[i].Type == api.NodeHostName {
addressNodeHostName = &nodeAddresses[i]
break
}
}
if addressNodeHostName == nil {
hostnameAddress := api.NodeAddress{Type: api.NodeHostName, Address: kl.GetHostname()}
node.Status.Addresses = append(nodeAddresses, hostnameAddress)
} else {
glog.V(2).Infof("Using Node Hostname from cloudprovider: %q", addressNodeHostName.Address)
}
} else {
var ipAddr net.IP
var err error
Expand Down