Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk/NodeExpandVolume: return NotFound if VolumePath not found #986

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/disk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package disk
import (
"context"
"crypto/sha256"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -913,6 +914,9 @@ func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV
log.Infof("NodeExpandVolume:: volumeId: %s, devicePath: %s, volumePath: %s", diskID, devicePaths, volumePath)
beforeResizeDiskCapacity, err := getDiskCapacity(volumePath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, status.Error(codes.NotFound, fmt.Sprintf("volumePath does not exist: %v", err))
}
log.Errorf("NodeExpandVolume:: get diskCapacity error %+v", err)
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/disk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ func getDiskCapacity(devicePath string) (float64, error) {

if err != nil {
log.Errorf("getDiskCapacity:: get device error: %+v", err)
return 0, fmt.Errorf("getDiskCapacity:: get device error: %+v", err)
return 0, fmt.Errorf("getDiskCapacity:: get device error: %w", err)
}

return float64(statfs.Blocks*uint64(statfs.Bsize)) / GBSIZE, nil
Expand Down