Skip to content

Commit

Permalink
csi: Remove NOT_FOUND error from ControllerUnpublishVolume() implemen…
Browse files Browse the repository at this point in the history
…tation

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
container-storage-interface/spec#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 <shuo@rancher.com>
  • Loading branch information
Shuo Wu committed Nov 4, 2019
1 parent 3380859 commit bf50c5a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion csi/controller_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit bf50c5a

Please # to comment.