From a52b909289fe58db21b98af209f260e0e155e4ea Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 20 Jan 2025 16:55:11 -0600 Subject: [PATCH] Avoid panic if creating volume from source fails If a driver advertises CREATE_DELETE_SNAPSHOT but fails to obey the part of the spec about allowing CreateVolume from a snapshot (such as during an incremental development of a driver), the testsuite was panicking on a nil dereference instead of diagnosing that an unexpected error was returned. Fixes: https://github.com/kubernetes-csi/csi-test/issues/569 Signed-off-by: Eric Blake --- pkg/sanity/controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sanity/controller.go b/pkg/sanity/controller.go index cf23d903..d56f465d 100644 --- a/pkg/sanity/controller.go +++ b/pkg/sanity/controller.go @@ -581,8 +581,9 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo }, } vol, err := r.CreateVolume(context.Background(), vol2Req) - Expect(vol.GetVolume().ContentSource).NotTo(BeNil()) Expect(err).NotTo(HaveOccurred()) + Expect(vol).NotTo(BeNil()) + Expect(vol.GetVolume().ContentSource).NotTo(BeNil()) }) It("should fail when the volume source snapshot is not found", func() {