Skip to content
Snippets Groups Projects
Unverified Commit 125ec1bc authored by Lukas Kämmerling's avatar Lukas Kämmerling Committed by GitHub
Browse files

Fix Detach deleted volume should not return NOT FOUND (#123)

parent 257ac44d
Branches
Tags
No related merge requests found
# Changes
## master
- Fix stuck volume terminating when the volume was already deleted
## v1.3.1
- Add correct deployment file for latest version
......
......@@ -241,6 +241,14 @@ func (s *VolumeService) Detach(ctx context.Context, volume *csi.Volume, server *
hcloudVolume, _, err := s.client.Volume.GetByID(ctx, int(volume.ID))
if err != nil {
if hcloud.IsError(err, hcloud.ErrorCodeNotFound) {
level.Info(s.logger).Log(
"msg", "volume to detach not found",
"volume-id", volume.ID,
"err", err,
)
return volumes.ErrVolumeNotFound
}
level.Info(s.logger).Log(
"msg", "failed to get volume to detach",
"volume-id", volume.ID,
......
......@@ -196,8 +196,9 @@ func (s *ControllerService) ControllerUnpublishVolume(ctx context.Context, req *
if err := s.volumeService.Detach(ctx, volume, server); err != nil {
code := codes.Internal
switch err {
case volumes.ErrVolumeNotFound:
code = codes.NotFound
case volumes.ErrVolumeNotFound: // Based on the spec it is save to assume that the call was successful if the volume is not found
resp := &proto.ControllerUnpublishVolumeResponse{}
return resp, nil
case volumes.ErrServerNotFound:
code = codes.NotFound
case volumes.ErrLockedServer:
......
......@@ -682,11 +682,6 @@ func TestControllerServiceUnpublishVolumeDetachErrors(t *testing.T) {
DetachError error
Code codes.Code
}{
{
Name: "volume not found",
DetachError: volumes.ErrVolumeNotFound,
Code: codes.NotFound,
},
{
Name: "server not found",
DetachError: volumes.ErrServerNotFound,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment