Skip to content

Commit 14469a7

Browse files
committed
map insufficient free space error during cache creating to InvalidArgument error
1 parent c653070 commit 14469a7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/gce-pd-csi-driver/cache.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111

1212
csi "github.com/container-storage-interface/spec/lib/go/csi"
1313
fsnotify "github.com/fsnotify/fsnotify"
14+
"google.golang.org/grpc/codes"
15+
"google.golang.org/grpc/status"
1416
v1 "k8s.io/api/core/v1"
1517
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1618
"k8s.io/apimachinery/pkg/util/wait"
@@ -159,13 +161,16 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
159161
}
160162
info, err = common.RunCommand("" /* pipedCmd */, nil /* pipedCmdArg */, "lvcreate", args...)
161163
if err != nil {
164+
if strings.Contains(err.Error(), "insufficient free space") {
165+
return mainDevicePath, status.Error(codes.InvalidArgument, fmt.Sprintf("Error setting up cache: %v", err.Error()))
166+
}
162167
return mainDevicePath, fmt.Errorf("Errored setting up logical volume for the volume %s %w: %s", devicePath, err, info)
163168
}
164169

165170
}
166171
err, isCached := isCachingSetup(mainLvName)
167172
if err != nil {
168-
klog.Errorf("faild to check if caching ius setup for LV, continuing to setup caching.")
173+
klog.Errorf("failed to check if caching is setup for LV, continuing to setup caching.")
169174
}
170175
cacheLvName := getLvName(cacheSuffix, volumeId)
171176
if isCached {

pkg/gce-pd-csi-driver/node.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
357357
}
358358
devicePath, err = setupCaching(devFsPath, req, nodeId)
359359
if err != nil {
360+
errStatus, _ := status.FromError(err)
361+
if errStatus.Code() == codes.InvalidArgument {
362+
return nil, err
363+
}
360364
return nil, status.Error(codes.DataLoss, fmt.Sprintf("Error setting up cache: %v", err.Error()))
361365
}
362366
}

0 commit comments

Comments
 (0)