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

Empty Subnet for Network Interfaces #23611

Open
dnaeon opened this issue Oct 21, 2024 · 8 comments
Open

Empty Subnet for Network Interfaces #23611

dnaeon opened this issue Oct 21, 2024 · 8 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Network question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@dnaeon
Copy link

dnaeon commented Oct 21, 2024

Bug Report

I'm using sdk/resourcemanager/network/armnetwork/v6 SDK in order to get the existing Network Interfaces.

Go version: go version go1.23.2 darwin/arm64

SDK version: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6 v6.1.0

When getting the Network Interfaces via the SDK the Subnet field is always nil.

The following example program prints the network interfaces from a given subscription and resource group.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6"
)

func printErr(err error) {
	fmt.Println(err)
	os.Exit(1)
}

func main() {
	opts := &azidentity.DefaultAzureCredentialOptions{
		TenantID: "my-tenant-uuid",
	}

	creds, err := azidentity.NewDefaultAzureCredential(opts)
	if err != nil {
		printErr(err)
	}

	printNetworkInterfaces(context.Background(), creds, "my-subscription-uuid", "my-rg")
}

func printNetworkInterfaces(ctx context.Context, creds azcore.TokenCredential, subscriptionID string, resourceGroup string) {
	factory, err := armnetwork.NewClientFactory(subscriptionID, creds, &arm.ClientOptions{})
	if err != nil {
		printErr(err)
	}

	client := factory.NewInterfacesClient()
	pager := client.NewListPager(resourceGroup, &armnetwork.InterfacesClientListOptions{})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			printErr(err)
		}

		for _, item := range page.Value {
			fmt.Printf("ID: %s\n", *item.ID)
			if item.Properties != nil {
				if item.Properties.IPConfigurations != nil {
					for _, ip := range item.Properties.IPConfigurations {
						if ip.Properties != nil {
							fmt.Printf("\tPrivate IP: %s\n", *ip.Properties.PrivateIPAddress)
							fmt.Printf("\tAllocation method: %s\n", *ip.Properties.PrivateIPAllocationMethod)
							fmt.Printf("\tSubnet: %v\n", ip.Properties.Subnet.Name) // Always `nil'
						}
					}
				}
			}
		}
	}
}

Sample result.

ID: /subscriptions/my-subscription-uuid/resourceGroups/my-rg/providers/Microsoft.Network/networkInterfaces/my-nic-1
        Private IP: 10.xxx.yyy.zzz
        Alloc method: Dynamic
        Subnet: <nil>

ID: /subscriptions/my-subscription-uuid/resourceGroups/my-rg/providers/Microsoft.Network/networkInterfaces/my-nic-2
        Private IP: 10.aaa.bbb.ccc
        Alloc method: Dynamic
        Subnet: <nil>

Getting the Network Interfaces using the CLI (az network nic list) works as expected, however when using the SDK I always get nil values for the Subnet.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 21, 2024
@lirenhe lirenhe added the Mgmt This issue is related to a management-plane library. label Oct 24, 2024
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 24, 2024
@lirenhe
Copy link
Member

lirenhe commented Oct 24, 2024

@dnaeon, could you turn on logging by setting environment variable AZURE_SDK_GO_LOGGING to all and configure policy.LogOption to print the body of this call? Please help to check whether you could receive subnet info in the raw response.

https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/new-version-guideline.md#logging

@dnaeon
Copy link
Author

dnaeon commented Oct 24, 2024

Hey @lirenhe ,

I've just enabled logging and printed the body of the response. I can see the subnet being part of the body, so this seems like an issue related to the SDK itself.

Thanks!

@lirenhe
Copy link
Member

lirenhe commented Nov 11, 2024

@jliusan, could you help to investigate the root cause?

@tadelesh
Copy link
Member

@dnaeon the Subnet.ID is available, but the service does not return Subnet.Name. the sdk behavior is correct.

@tadelesh tadelesh added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Nov 14, 2024
Copy link

Hi @dnaeon. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@dnaeon
Copy link
Author

dnaeon commented Nov 14, 2024

@tadelesh According to the Subnet SDK documentation the Name should be "unique within a resource group. This name can be used to access the resource"

// Subnet in a virtual network resource.
type Subnet struct {
	// Resource ID.
	ID *string

	// The name of the resource that is unique within a resource group. This name can be used to access the resource.
	Name *string

	// Properties of the subnet.
	Properties *SubnetPropertiesFormat

	// Resource type.
	Type *string

	// READ-ONLY; A unique read-only string that changes whenever the resource is updated.
	Etag *string
}

Having the Subnet.Name be nil for every interface does not seem correct to me.

Thanks,
Marin

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Nov 14, 2024
@tadelesh
Copy link
Member

@dnaeon our sdk is auto-generated from the service spec, and does not have any convenience code like cli does. since service does not return the subnet name, the sdk returns nil is by design. i'll call for help from service team. meantime, i suggest you open a ticket in icm to have more efficient resp from service team.

@tadelesh tadelesh added Network Service Attention Workflow: This issue is responsible by Azure service team. labels Nov 15, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Network question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants