@@ -187,7 +187,7 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, input cleanupInput) {
187
187
// that cluster variable is not set even if the cluster exists, so we are calling DeleteAllClustersAndWait
188
188
// instead of DeleteClusterAndWait
189
189
deleteTimeoutConfig := "wait-delete-cluster"
190
- if strings .Contains (input .Cluster .Name , aksClusterNameSuffix ) {
190
+ if input . Cluster != nil && strings .Contains (input .Cluster .Name , aksClusterNameSuffix ) {
191
191
deleteTimeoutConfig = "wait-delete-cluster-aks"
192
192
}
193
193
framework .DeleteAllClustersAndWait (ctx , framework.DeleteAllClustersAndWaitInput {
@@ -218,11 +218,15 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, input cleanupInput) {
218
218
// ExpectResourceGroupToBe404 performs a GET request to Azure to determine if the cluster resource group still exists.
219
219
// If it does still exist, it means the cluster was not deleted and is leaking Azure resources.
220
220
func ExpectResourceGroupToBe404 (ctx context.Context ) {
221
+ resourceGroup := os .Getenv (AzureResourceGroup )
222
+ if resourceGroup == "" {
223
+ return
224
+ }
221
225
cred , err := azidentity .NewDefaultAzureCredential (nil )
222
226
Expect (err ).NotTo (HaveOccurred ())
223
227
groupsClient , err := armresources .NewResourceGroupsClient (getSubscriptionID (Default ), cred , nil )
224
228
Expect (err ).NotTo (HaveOccurred ())
225
- _ , err = groupsClient .Get (ctx , os . Getenv ( AzureResourceGroup ) , nil )
229
+ _ , err = groupsClient .Get (ctx , resourceGroup , nil )
226
230
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." )
227
231
}
228
232
0 commit comments