From 6357c391f9980e7a00ff59fe5322f621041feee1 Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Tue, 15 Nov 2016 12:59:40 -0800 Subject: [PATCH] azure: support nics with multiple ipconfigs --- pkg/cloudprovider/providers/azure/azure_util.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/cloudprovider/providers/azure/azure_util.go b/pkg/cloudprovider/providers/azure/azure_util.go index 2f31cab9ac2..c020671042b 100644 --- a/pkg/cloudprovider/providers/azure/azure_util.go +++ b/pkg/cloudprovider/providers/azure/azure_util.go @@ -151,9 +151,12 @@ func getPrimaryIPConfig(nic network.Interface) (*network.InterfaceIPConfiguratio return &((*nic.Properties.IPConfigurations)[0]), nil } - // we're here because we either have multiple ipconfigs and can't determine the primary: - // https://github.com/Azure/azure-rest-api-specs/issues/305 - // or somehow we had zero ipconfigs + for _, ref := range *nic.Properties.IPConfigurations { + if *ref.Properties.Primary { + return &ref, nil + } + } + return nil, fmt.Errorf("failed to determine the determine primary ipconfig. nicname=%q", *nic.Name) }