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

Specifying Multiple IP Configurations per Network Interface #259

Closed
stack72 opened this issue Jan 10, 2016 · 8 comments
Closed

Specifying Multiple IP Configurations per Network Interface #259

stack72 opened this issue Jan 10, 2016 · 8 comments

Comments

@stack72
Copy link

stack72 commented Jan 10, 2016

I am trying to make the following call to the API:

{
    "name": "acceptanceTestNetworkInterface1",
    "location": "westus",
    "properties": {
        "ipConfigurations": [{
            "properties": {
                "loadBalancerBackendAddressPools": null,
                "loadBalancerInboundNatRules": null,
                "privateIPAllocationMethod": "dynamic",
                "subnet": {
                    "id": "/subscriptions/xxxx/resourceGroups/acceptanceTestResourceGroup1/providers/Microsoft.Network/virtualNetworks/acceptanceTestVirtualNetwork1/subnets/testsubnet1"
                }
            },
            "name": "testconfiguration2"
        }, {
            "properties": {
                "loadBalancerBackendAddressPools": null,
                "loadBalancerInboundNatRules": null,
                "privateIPAllocationMethod": "dynamic",
                "subnet": {
                    "id": "/subscriptions/xxxx/resourceGroups/acceptanceTestResourceGroup1/providers/Microsoft.Network/virtualNetworks/acceptanceTestVirtualNetwork1/subnets/testsubnet"
                }
            },
            "name": "testconfiguration1"
        }],
    }
}

I get the following response:

{
    "error": {
        "code": "NetworkInterfaceMustHaveOneOneIPConfigAsPrimary",
        "message": "Network Interface acceptanceTestNetworkInterface1 specifies multiple IPConfigurations but none of the IPConfigurations is specified as Primary.",
        "details": []
    }
}

The struct for the network interface looks as follows:

type Interface struct {
    autorest.Response `json:"-"`
    ID                *string                    `json:"id,omitempty"`
    Name              *string                    `json:"name,omitempty"`
    Type              *string                    `json:"type,omitempty"`
    Location          *string                    `json:"location,omitempty"`
    Tags              *map[string]*string        `json:"tags,omitempty"`
    Properties        *InterfacePropertiesFormat `json:"properties,omitempty"`
    Etag              *string                    `json:"etag,omitempty"`
}

type InterfacePropertiesFormat struct {
    VirtualMachine       *SubResource                `json:"virtualMachine,omitempty"`
    NetworkSecurityGroup *SecurityGroup              `json:"networkSecurityGroup,omitempty"`
    IPConfigurations     *[]InterfaceIPConfiguration `json:"ipConfigurations,omitempty"`
    DNSSettings          *InterfaceDNSSettings       `json:"dnsSettings,omitempty"`
    MacAddress           *string                     `json:"macAddress,omitempty"`
    Primary              *bool                       `json:"primary,omitempty"`
    EnableIPForwarding   *bool                       `json:"enableIPForwarding,omitempty"`
    ResourceGUID         *string                     `json:"resourceGuid,omitempty"`
    ProvisioningState    *string                     `json:"provisioningState,omitempty"`
}

The Primary is outside of the IPConfigurations. Therefore, we cannot pass primary: true for any of the IPConfigurations. The correct request should look as follows:

{
    "name": "acceptanceTestNetworkInterface1",
    "location": "westus",
    "properties": {
        "ipConfigurations": [{
            "properties": {
                "loadBalancerBackendAddressPools": null,
                "loadBalancerInboundNatRules": null,
                "privateIPAllocationMethod": "dynamic",
                "subnet": {
                    "id": "/subscriptions/xxxx/resourceGroups/acceptanceTestResourceGroup1/providers/Microsoft.Network/virtualNetworks/acceptanceTestVirtualNetwork1/subnets/testsubnet1"
                }
            },
            "name": "testconfiguration2"
        }, {
            "properties": {
                "loadBalancerBackendAddressPools": null,
                "loadBalancerInboundNatRules": null,
                "privateIPAllocationMethod": "dynamic",
                "subnet": {
                    "id": "/subscriptions/xxxx/resourceGroups/acceptanceTestResourceGroup1/providers/Microsoft.Network/virtualNetworks/acceptanceTestVirtualNetwork1/subnets/testsubnet"
                }
                                "primary": true
            },
            "name": "testconfiguration1"
        }],
    }
}
@jen20
Copy link
Contributor

jen20 commented Jan 10, 2016

I haven't looked into the Swagger yet but can verify the structures in the generated client do not match what is running in production, and it is therefore impossible to create a network interface with multiple IP configurations without hacking around the SDK at present - for now we've just documented it as a bug in the Terraform docs, and will update when this is fixed.

@brendandixon
Copy link
Contributor

The issue comes from the Swagger. I've verified that it is in both the Network/2015-06-15 and prior version. See https://github.com/Azure/azure-rest-api-specs/blob/master/arm-network/2015-06-15/swagger/network.json#L5849.

If you would not mind, please, post an issue against that repository. I'll poke around as well.

@DeepakRajendranMsft
Copy link

Hi @stack72,

Thanks for pointing this out. The "primary" flag outside IPConfiguration is valid since we support MultiNic scenario. So the flag will tell the user whether the nic is a primary or not.

Yes, though we have IPConfiguration as a list, we are currently working on Multiple IPConfiguration support (once that is done, we will update the schema and the client with the "primary" field). This currently is a bug on the service where we are not throwing the appropriate error message. (the message should be something along the lines of "Multiple IPConfigurations not supported"). We will fix this soon.

Thanks,
Deepak.

Felivel added a commit to Felivel/terraform that referenced this issue May 9, 2016
stack72 pushed a commit to hashicorp/terraform that referenced this issue May 9, 2016
* Adding private ip address reference

* adding private ip address reference
* Updating the docs.

* Removing optional attrib from private_ip_address

Removing optional attribute from private_ip_address, this element is only being used in the read.

* Selecting the first element instead of using a loop for now.
Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
@colemickens
Copy link
Contributor

@DeepakRajendranMsft

I don't understand. When I query for my NIC in resources.azure.com, I can see the ipConfiguration itself has a primary field that is populated.

On the other hand, when I query my VM and inspect the NetworkProfile, the Primary field is NOT populated on the interface.

This indicates to me that the Swagger does not conform to the actual behavior of the API. I'm actively having to work around this by making certain assumptions.

@colemickens
Copy link
Contributor

colemickens commented May 18, 2016

@DeepakRajendranMsft

GET https://management.azure.com/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Compute/virtualMachines/master?api-version=2016-03-30

[...]
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Network/networkInterfaces/master815"
        }
      ]
    },
[...]

So this does not contain the primary field, despite the Swagger spec saying that it would.

And then:

GET https://management.azure.com/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Network/networkInterfaces/master815?api-version=2016-03-30

[...]
"ipConfigurations": [
      {
        "name": "ipconfig1",
        "id": "/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Network/networkInterfaces/master815/ipConfigurations/ipconfig1",
        "etag": "W/\"fdea6b24-7abe-4f57-986e-c27e14eff876\"",
        "properties": {
          "provisioningState": "Succeeded",
          "privateIPAddress": "10.0.0.4",
          "privateIPAllocationMethod": "Dynamic",
          "publicIPAddress": {
            "id": "/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Network/publicIPAddresses/master"
          },
          "subnet": {
            "id": "/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Network/virtualNetworks/colemick-kube-vnet/subnets/colemick-kube-nodes"
          },
          "primary": true,
          "privateIPAddressVersion": "IPv4",
          "loadBalancerBackendAddressPools": [
            {
              "id": "/subscriptions/27b750cd-ed43-42fd-9044-8d75e124ae55/resourceGroups/colemick-kube-ubuntu-0/providers/Microsoft.Network/loadBalancers/aafdf4dfe1a8b11e6a4f2000d3a332e1/backendAddressPools/aafdf4dfe1a8b11e6a4f2000d3a332e1"
            }
          ]
        }
      }
[...]

Which shows the ipConfiguration coming back with a "primary" field, and yet this isn't exposed in Swagger.

The net result is that I can't tell which NIC is primary, and I can't tell which ipConfiguration on a given NIC is primary. This does not seem correct to me.

cristicalin pushed a commit to cristicalin/terraform that referenced this issue May 24, 2016
…hicorp#6538)

* Adding private ip address reference

* adding private ip address reference
* Updating the docs.

* Removing optional attrib from private_ip_address

Removing optional attribute from private_ip_address, this element is only being used in the read.

* Selecting the first element instead of using a loop for now.
Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
@ahmetb
Copy link
Contributor

ahmetb commented Aug 2, 2016

@colemickens do you know if this is fixed?

@colemickens
Copy link
Contributor

Not really. The other thread: Azure/azure-rest-api-specs#305 has open questions about if this has been addressed appropriately. I'll ping that thread.

@colemickens
Copy link
Contributor

This is resolved. See here for the details: Azure/azure-rest-api-specs#305 (comment)

grubernaut pushed a commit to hashicorp/terraform-provider-azurerm that referenced this issue Jun 6, 2017
* Adding private ip address reference

* adding private ip address reference
* Updating the docs.

* Removing optional attrib from private_ip_address

Removing optional attribute from private_ip_address, this element is only being used in the read.

* Selecting the first element instead of using a loop for now.
Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
grubernaut pushed a commit to hashicorp/terraform-provider-azurerm that referenced this issue Jun 9, 2017
* Adding private ip address reference

* adding private ip address reference
* Updating the docs.

* Removing optional attrib from private_ip_address

Removing optional attribute from private_ip_address, this element is only being used in the read.

* Selecting the first element instead of using a loop for now.
Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants