@@ -187,7 +187,7 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, input cleanupInput) {
187187 // that cluster variable is not set even if the cluster exists, so we are calling DeleteAllClustersAndWait
188188 // instead of DeleteClusterAndWait
189189 deleteTimeoutConfig := "wait-delete-cluster"
190- if strings .Contains (input .Cluster .Name , aksClusterNameSuffix ) {
190+ if input . Cluster != nil && strings .Contains (input .Cluster .Name , aksClusterNameSuffix ) {
191191 deleteTimeoutConfig = "wait-delete-cluster-aks"
192192 }
193193 framework .DeleteAllClustersAndWait (ctx , framework.DeleteAllClustersAndWaitInput {
@@ -218,11 +218,15 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, input cleanupInput) {
218218// ExpectResourceGroupToBe404 performs a GET request to Azure to determine if the cluster resource group still exists.
219219// If it does still exist, it means the cluster was not deleted and is leaking Azure resources.
220220func ExpectResourceGroupToBe404 (ctx context.Context ) {
221+ resourceGroup := os .Getenv (AzureResourceGroup )
222+ if resourceGroup == "" {
223+ return
224+ }
221225 cred , err := azidentity .NewDefaultAzureCredential (nil )
222226 Expect (err ).NotTo (HaveOccurred ())
223227 groupsClient , err := armresources .NewResourceGroupsClient (getSubscriptionID (Default ), cred , nil )
224228 Expect (err ).NotTo (HaveOccurred ())
225- _ , err = groupsClient .Get (ctx , os . Getenv ( AzureResourceGroup ) , nil )
229+ _ , err = groupsClient .Get (ctx , resourceGroup , nil )
226230 Expect (azure .ResourceNotFound (err )).To (BeTrue (), "The resource group in Azure still exists. After deleting the cluster all of the Azure resources should also be deleted." )
227231}
228232
0 commit comments