azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[BUG] Unable to get reference to AKS cluster with kube-dashboard add-on explicitly disabled

Open brutusbuckeye opened this issue 3 years ago • 2 comments
trafficstars

Library name and version

Azure.ResourceManager.ContainerService 1.0.0-beta.2

Describe the bug

I am unable to get a reference to an AKS cluster that is using has the kube-dashboard add-on explicitly disabled. In debug more the code throws an exception as the code believes the code believes the config section underneath addonProfiles should never be null. In release builds no exception is thrown. The code should be modified as based on the following JSON snippet of my AKS cluster indicates that a null value for the kubeDashboard addon is acceptable.

"addonProfiles": {
            "kubeDashboard": {
                "enabled": false,
                "config": null
            }
        },

Expected behavior

The code should allow for addon profiles that do that null configuration as the code

Actual behavior

On debug the code verifies that the config property is not null as it incorrectly believes this property is non-nullable: https://github.com/Azure/azure-sdk-for-net/blob/61bd4c4275ad21c4ac18213e9a6fe0b6d3c6b954/sdk/containerservice/Azure.ResourceManager.ContainerService/src/Generated/Models/ManagedClusterAddonProfile.Serialization.cs#L49

However, based on my valid AKS cluster the config property is allowed to be null.

Reproduction Steps

Create an AKS cluster and disable the kube-dashboard add-on:

az group create --name myResourceGroup --location eastus
az aks create -g myResourceGroup -n myCluster
az aks addon disable  -g myResourceGroup -n myCluster -a kube-dashboard

Optional: Browse to the cluster in the portal and view the cluster JSON. Notice the kube-dashboard has a null config.

Then run the following code snippet to access the cluster using the azure sdk for dot net:

ArmClient client = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = client.GetSubscriptionResource(SubscriptionResource.CreateResourceIdentifier("----- subscription id -----"));
ResourceGroupResource resourceGroup = subscription.GetResourceGroup("myResourceGroup");

// getting a reference to a cluster with this addon disabled triggers an exception
ContainerServiceManagedClusterResource cluster = resourceGroup.GetContainerServiceManagedCluster("myCluster");

Environment

dotnet --info returns the following:

.NET SDK (reflecting any global.json):
 Version:   6.0.401
 Commit:    0906eae6f8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.401\

global.json file:
  Not found

Host:
  Version:      6.0.9
  Architecture: x64
  Commit:       163a63591c

brutusbuckeye avatar Sep 19 '22 14:09 brutusbuckeye

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Sep 19 '22 17:09 jsquire

Hi @brutusbuckeye thank you for the issue. We are aware of this issue and tracking it here: https://github.com/Azure/autorest.csharp/issues/2792 We plan to make some enhancement around this so that we could handle the null values more gracefully.

ArcturusZhang avatar Feb 15 '23 06:02 ArcturusZhang