From 4b98902b17f624d3eb6f2e011b222cd8a9e24f20 Mon Sep 17 00:00:00 2001 From: Shuo Wu Date: Fri, 1 Nov 2019 10:32:43 -0700 Subject: [PATCH] csi: Remove NOT_FOUND error from ControllerUnpublishVolume() implementation Now the provisioner won't wait for Detach (ControllerUnpublishVolume()) complete before invoking DeleteVolume. Then Detach will get stuck in the NOT_FOUND error since there is no way to verify the volume before detaching. For the details, See https://github.com/container-storage-interface/spec/issues/382 And the spec doc has removed NOT_FOUND error for ControllerUnpublishVolume(): https://github.com/container-storage-interface/spec/blob/release-1.2/spec.md#controllerunpublishvolume Signed-off-by: Shuo Wu --- csi/controller_server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/csi/controller_server.go b/csi/controller_server.go index e584a49ac9..a53d33266e 100644 --- a/csi/controller_server.go +++ b/csi/controller_server.go @@ -225,11 +225,15 @@ func (cs *ControllerServer) ControllerUnpublishVolume(ctx context.Context, req * if err != nil { return nil, status.Error(codes.Internal, err.Error()) } + + // VOLUME_NOT_FOUND is no longer the ControllerUnpublishVolume error + // See https://github.com/container-storage-interface/spec/issues/382 for details if existVol == nil { msg := fmt.Sprintf("ControllerUnpublishVolume: the volume %s not exists", req.GetVolumeId()) logrus.Warn(msg) - return nil, status.Error(codes.NotFound, msg) + return &csi.ControllerUnpublishVolumeResponse{}, nil } + if existVol.State == string(types.VolumeStateDetaching) { return nil, status.Errorf(codes.Aborted, "The volume %s is detaching", req.GetVolumeId()) }