From 9f5b6db8be8e5f531918751e7c5b2c34f38df474 Mon Sep 17 00:00:00 2001 From: Rafael Fonseca Date: Thu, 13 Jul 2023 09:04:24 +0200 Subject: [PATCH] test: azure: check error for cloud detection. If something goes wrong during the Azure cloud detection, trying to cast the returned value will result in the following panic and give no clue as to what the error was. ``` panic: interface conversion: cloudprovider.Interface is nil, not *azure.Cloud goroutine 1 [running]: k8s.io/kubernetes/test/e2e/framework/providers/azure.newProvider() test/e2e/framework/providers/azure/azure.go:50 +0x2b5 k8s.io/kubernetes/test/e2e/framework.SetupProviderConfig({0xc0007966b8, 0x5}) test/e2e/framework/provider.go:82 +0x1a6 ``` --- test/e2e/framework/providers/azure/azure.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/e2e/framework/providers/azure/azure.go b/test/e2e/framework/providers/azure/azure.go index 7c6bb217dfa..926022b4310 100644 --- a/test/e2e/framework/providers/azure/azure.go +++ b/test/e2e/framework/providers/azure/azure.go @@ -46,9 +46,12 @@ func newProvider() (framework.ProviderInterface, error) { defer config.Close() } azureCloud, err := azure.NewCloud(config) + if err != nil { + return nil, err + } return &Provider{ azureCloud: azureCloud.(*azure.Cloud), - }, err + }, nil } // Provider is a structure to handle Azure clouds for e2e testing