diff --git a/pkg/cloud/services/compute/instance_types.go b/pkg/cloud/services/compute/instance_types.go index 6726d0cca3..40bc24b031 100644 --- a/pkg/cloud/services/compute/instance_types.go +++ b/pkg/cloud/services/compute/instance_types.go @@ -157,7 +157,7 @@ func (is *InstanceStatus) NetworkStatus() (*InstanceNetworkStatus, error) { // Only consider IPv4 if address.Version != 4 { - is.logger.V(6).Info("Ignoring IPv%d address %s: only IPv4 is supported", address.Version, address.Address) + is.logger.V(6).Info("Ignoring IP address: only IPv4 is supported", "version", address.Version, "address", address.Address) continue } @@ -168,7 +168,7 @@ func (is *InstanceStatus) NetworkStatus() (*InstanceNetworkStatus, error) { case "fixed": addressType = corev1.NodeInternalIP default: - is.logger.V(6).Info("Ignoring address %s with unknown type '%s'", address.Address, address.Type) + is.logger.V(6).Info("Ignoring address with unknown type", "address", address.Address, "type", address.Type) continue } diff --git a/pkg/cloud/services/compute/instance_types_test.go b/pkg/cloud/services/compute/instance_types_test.go index de161643c9..5ffb3d5861 100644 --- a/pkg/cloud/services/compute/instance_types_test.go +++ b/pkg/cloud/services/compute/instance_types_test.go @@ -276,6 +276,37 @@ func TestInstanceNetworkStatus(t *testing.T) { wantIP: "192.168.0.1", wantFloatingIP: "10.0.0.1", }, + { + name: "Ignore unknown address type", + addresses: map[string][]networkAddress{ + "primary": { + { + Version: 4, + Addr: "192.168.0.2", + Type: "not-valid", + MacAddr: macAddr1, + }, { + Version: 4, + Addr: "192.168.0.3", + Type: "unknown", + MacAddr: macAddr2, + }, { + Version: 4, + Addr: "10.0.0.1", + Type: "floating", + MacAddr: macAddr3, + }, { + Version: 4, + Addr: "192.168.0.1", + Type: "fixed", + MacAddr: macAddr4, + }, + }, + }, + networkName: "primary", + wantIP: "192.168.0.1", + wantFloatingIP: "10.0.0.1", + }, { name: "Multiple networks", addresses: map[string][]networkAddress{