From 1b608aa2c04cd41ca7d5d83a133f0ac5633fda47 Mon Sep 17 00:00:00 2001 From: Grant Griffiths Date: Tue, 26 Nov 2019 15:07:25 -0800 Subject: [PATCH] CSI: Fix panic in NodeUnpublishVolume when err is nil (#1331) Signed-off-by: Grant Griffiths --- csi/node.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/csi/node.go b/csi/node.go index 8dae717ab..1c2b653b7 100644 --- a/csi/node.go +++ b/csi/node.go @@ -162,11 +162,14 @@ func (s *OsdCsiServer) NodeUnpublishVolume( if err == kvdb.ErrNotFound { logrus.Infof("Volume %s was deleted or cannot be found: %s", req.GetVolumeId(), err.Error()) return &csi.NodeUnpublishVolumeResponse{}, nil + } else if err != nil { + return nil, status.Errorf(codes.NotFound, "Volume id %s not found: %s", + req.GetVolumeId(), + err.Error()) + } else { + return nil, status.Errorf(codes.NotFound, "Volume id %s not found: Inspect returned no volumes", + req.GetVolumeId()) } - - return nil, status.Errorf(codes.NotFound, "Volume id %s not found: %s", - req.GetVolumeId(), - err.Error()) } vol := vols[0]