mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
addressed comments
This commit is contained in:
parent
43e606a5da
commit
8b16c3dafb
@ -983,12 +983,18 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]v1.NodeAddress, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, macID := range strings.Split(macs, "\n") {
|
for _, macID := range strings.Split(macs, "\n") {
|
||||||
|
if macID == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
macPath := path.Join("network/interfaces/macs/", macID, "local-ipv4s")
|
macPath := path.Join("network/interfaces/macs/", macID, "local-ipv4s")
|
||||||
internalIPs, err := c.metadata.GetMetadata(macPath)
|
internalIPs, err := c.metadata.GetMetadata(macPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error querying AWS metadata for %q: %q", macPath, err)
|
return nil, fmt.Errorf("error querying AWS metadata for %q: %q", macPath, err)
|
||||||
}
|
}
|
||||||
for _, internalIP := range strings.Split(internalIPs, "\n") {
|
for _, internalIP := range strings.Split(internalIPs, "\n") {
|
||||||
|
if internalIP == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalIP, Address: internalIP})
|
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalIP, Address: internalIP})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1043,20 +1049,18 @@ func extractNodeAddresses(instance *ec2.Instance) ([]v1.NodeAddress, error) {
|
|||||||
// handle internal network interfaces
|
// handle internal network interfaces
|
||||||
for _, networkInterface := range instance.NetworkInterfaces {
|
for _, networkInterface := range instance.NetworkInterfaces {
|
||||||
// skip network interfaces that are not currently in use
|
// skip network interfaces that are not currently in use
|
||||||
if isNilOrEmpty(networkInterface.Status) || *networkInterface.Status != ec2.NetworkInterfaceStatusInUse {
|
if aws.StringValue(networkInterface.Status) != ec2.NetworkInterfaceStatusInUse {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, internalIP := range networkInterface.PrivateIpAddresses {
|
for _, internalIP := range networkInterface.PrivateIpAddresses {
|
||||||
if !isNilOrEmpty(internalIP.PrivateIpAddress) {
|
if ipAddress := aws.StringValue(internalIP.PrivateIpAddress); ipAddress != "" {
|
||||||
ipAddress := *internalIP.PrivateIpAddress
|
|
||||||
ip := net.ParseIP(ipAddress)
|
ip := net.ParseIP(ipAddress)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return nil, fmt.Errorf("EC2 instance had invalid private address: %s (%s)", orEmpty(instance.InstanceId), ipAddress)
|
return nil, fmt.Errorf("EC2 instance had invalid private address: %s (%q)", aws.StringValue(instance.InstanceId), ipAddress)
|
||||||
}
|
}
|
||||||
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalIP, Address: ip.String()})
|
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalIP, Address: ip.String()})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user