Open
Description
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 asarmnetwork.ConnectionStatus
as listed atazure-sdk-for-go/sdk/resourcemanager/network/armnetwork/constants.go
Lines 1010 to 1017 in 0ab0cfb
- It seems like
"Reachable"
is actually aarmnetwork.ConnectionState
constant as seen atazure-sdk-for-go/sdk/resourcemanager/network/armnetwork/constants.go
Lines 992 to 998 in 0ab0cfb
- I expected
- 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.
- Run the function above with any reasonable parameters. May have to change the
- Anything we should know about your environment.
Metadata
Metadata
Assignees
Labels
This issue is related to a management-plane library.Workflow: This issue is responsible by Azure service team.Issues that are reported by GitHub users external to the Azure organization.Workflow: This issue needs attention from Azure service team or SDK teamThe issue doesn't require a change to the product in order to be resolved. Most issues start as that