Skip to content

Connectivity check returning a nonexistent ConnectionStatus constant #21777

Open
@seankimkdy

Description

@seankimkdy

Bug Report

  • import path of package: "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"
  • SDK version: v2.2.1
  • output of go version: go version go1.20.5 linux/amd64
  • What happened?
    I wrote a simple function to run a Connectivity Check using ICMP from an Azure VM to another IP address.
func RunPingConnectivityCheck(subscriptionID string, resourceGroupName string, sourceVMResourceID string, destinationIPAddress string) (bool, error) {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		return false, fmt.Errorf("unable to get azure credentials: %w", err)
	}
	watchersClient, err := armnetwork.NewWatchersClient(subscriptionID, cred, nil)
	if err != nil {
		return false, fmt.Errorf("unable to create compute client factory: %w", err)
	}
	ctx := context.Background()

	connectivityParameters := armnetwork.ConnectivityParameters{
		Destination:        &armnetwork.ConnectivityDestination{Address: to.Ptr(destinationIPAddress)},
		Source:             &armnetwork.ConnectivitySource{ResourceID: to.Ptr(sourceVMResourceID)},
		PreferredIPVersion: to.Ptr(armnetwork.IPVersionIPv4),
		Protocol:           to.Ptr(armnetwork.ProtocolIcmp),
	}
	pollerResponse, err := watchersClient.BeginCheckConnectivity(ctx, "NetworkWatcherRG", "NetworkWatcher_westus", connectivityParameters, nil)
	if err != nil {
		return false, err
	}
	resp, err := pollerResponse.PollUntilDone(ctx, nil)
	if err != nil {
		return false, err
	}
	fmt.Printf("ConnectionStatus: %s\n", *resp.ConnectivityInformation.ConnectionStatus)
	fmt.Printf("ConnectionStatus Type: %T\n", *resp.ConnectivityInformation.ConnectionStatus)

	// Unclear why ConnectionStatus returns "Reachable" which is not a valid armnetwork.ConnectionStatus
	return *resp.ConnectivityInformation.ConnectionStatus == armnetwork.ConnectionStatus("Reachable"), nil
}

The output, if connectivity check is successful, is

ConnectionStatus: Reachable
ConnectionStatus Type: armnetwork.ConnectionStatus
  • What did you expect or want to happen?
    • I expected resp.ConnectivityInformation.ConnectionStatus to be one of the constants defined as armnetwork.ConnectionStatus as listed at
      type ConnectionStatus string
      const (
      ConnectionStatusConnected ConnectionStatus = "Connected"
      ConnectionStatusDegraded ConnectionStatus = "Degraded"
      ConnectionStatusDisconnected ConnectionStatus = "Disconnected"
      ConnectionStatusUnknown ConnectionStatus = "Unknown"
      )
    • It seems like "Reachable" is actually a armnetwork.ConnectionState constant as seen at
      type ConnectionState string
      const (
      ConnectionStateReachable ConnectionState = "Reachable"
      ConnectionStateUnknown ConnectionState = "Unknown"
      ConnectionStateUnreachable ConnectionState = "Unreachable"
      )
  • How can we reproduce it?
    • Run the function above with any reasonable parameters. May have to change the "NetworkWatcher_westus to the right network watcher name depending on where the VM is located.
  • Anything we should know about your environment.

Metadata

Metadata

Assignees

Labels

MgmtThis issue is related to a management-plane library.Network - Virtual NetworkService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions