Skip to content

Commit

Permalink
Fixes for Delete
Browse files Browse the repository at this point in the history
  • Loading branch information
bertinatto committed Jul 10, 2024
1 parent 98616b7 commit 41a3d49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
return &csi.DeleteVolumeResponse{}, nil
}

//TODO: Add Delete File System when FS provisioning is implemented
if accessPointId != "" {
err := d.provisioners[AccessPointMode].Delete(ctx, req)
if err != nil {
return nil, status.Errorf(codes.Internal, "Failed to Delete volume %v: %v", volId, err)
return nil, err
}
} else {
return nil, status.Errorf(codes.NotFound, "Failed to find access point for volume: %v", volId)
Expand Down
23 changes: 11 additions & 12 deletions pkg/driver/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,18 @@ func (a AccessPointProvisioner) Delete(ctx context.Context, req *csi.DeleteVolum
return status.Errorf(codes.Internal, "Could not delete %q: %v", target, err)
}

// Delete access point
if err = localCloud.DeleteAccessPoint(ctx, accessPointId); err != nil {
if err == cloud.ErrAccessDenied {
return status.Errorf(codes.Unauthenticated, "Access Denied. Please ensure you have the right AWS permissions: %v", err)
}
if err == cloud.ErrNotFound {
klog.V(5).Infof("DeleteVolume: Access Point not found, returning success")
return nil
}
return status.Errorf(codes.Internal, "Failed to Delete volume %v: %v", volId, err)
}

// Delete access point
if err = localCloud.DeleteAccessPoint(ctx, accessPointId); err != nil {
if err == cloud.ErrAccessDenied {
return status.Errorf(codes.Unauthenticated, "Access Denied. Please ensure you have the right AWS permissions: %v", err)
}
} else {
return status.Errorf(codes.NotFound, "Failed to find access point for volume: %v", volId)
if err == cloud.ErrNotFound {
klog.V(5).Infof("DeleteVolume: Access Point not found, returning success")
return nil
}
return status.Errorf(codes.Internal, "Failed to Delete volume %v: %v", volId, err)
}

return nil
Expand Down

0 comments on commit 41a3d49

Please sign in to comment.