Skip to content

Map insufficient free space error during cache creating to InvalidArgument error #2010

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

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
8 changes: 7 additions & 1 deletion pkg/gce-pd-csi-driver/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (

csi "github.com/container-storage-interface/spec/lib/go/csi"
fsnotify "github.com/fsnotify/fsnotify"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -165,7 +167,7 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
}
err, isCached := isCachingSetup(mainLvName)
if err != nil {
klog.Errorf("faild to check if caching ius setup for LV, continuing to setup caching.")
klog.Errorf("failed to check if caching is setup for LV, continuing to setup caching.")
}
cacheLvName := getLvName(cacheSuffix, volumeId)
if isCached {
Expand Down Expand Up @@ -194,6 +196,9 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
}
info, err = common.RunCommand("" /* pipedCmd */, nil /* pipedCmdArg */, "lvcreate", args...)
if err != nil {
if strings.Contains(err.Error(), "insufficient free space") {
return mainDevicePath, status.Error(codes.InvalidArgument, fmt.Sprintf("Error setting up cache: %v", err.Error()))
}
return mainDevicePath, fmt.Errorf("Errored while creating cache %w: %s", err, info)
}
}
Expand Down Expand Up @@ -391,6 +396,7 @@ func checkVgExists(volumeGroupName string) bool {
return false
}
// Check if the required volume group already exists
klog.Infof("check vg exists output: %v, volumeGroupName: %v", string(info), volumeGroupName)
return strings.Contains(string(info), volumeGroupName)
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/gce-pd-csi-driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
}
devicePath, err = setupCaching(devFsPath, req, nodeId)
if err != nil {
errStatus, _ := status.FromError(err)
if errStatus.Code() == codes.InvalidArgument {
return nil, err
}
return nil, status.Error(codes.DataLoss, fmt.Sprintf("Error setting up cache: %v", err.Error()))
}
}
Expand Down