Skip to content

Commit 1790c03

Browse files
authoredMar 25, 2025
Merge pull request #2011 from k8s-infra-cherrypick-robot/cherry-pick-2010-to-release-1.17
[release-1.17] Map insufficient free space error during cache creating to InvalidArgument error
2 parents e76333d + d8767b4 commit 1790c03

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

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

+7-1
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"
@@ -165,7 +167,7 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
165167
}
166168
err, isCached := isCachingSetup(mainLvName)
167169
if err != nil {
168-
klog.Errorf("faild to check if caching ius setup for LV, continuing to setup caching.")
170+
klog.Errorf("failed to check if caching is setup for LV, continuing to setup caching.")
169171
}
170172
cacheLvName := getLvName(cacheSuffix, volumeId)
171173
if isCached {
@@ -194,6 +196,9 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
194196
}
195197
info, err = common.RunCommand("" /* pipedCmd */, nil /* pipedCmdArg */, "lvcreate", args...)
196198
if err != nil {
199+
if strings.Contains(err.Error(), "insufficient free space") {
200+
return mainDevicePath, status.Error(codes.InvalidArgument, fmt.Sprintf("Error setting up cache: %v", err.Error()))
201+
}
197202
return mainDevicePath, fmt.Errorf("Errored while creating cache %w: %s", err, info)
198203
}
199204
}
@@ -391,6 +396,7 @@ func checkVgExists(volumeGroupName string) bool {
391396
return false
392397
}
393398
// Check if the required volume group already exists
399+
klog.Infof("check vg exists output: %v, volumeGroupName: %v", string(info), volumeGroupName)
394400
return strings.Contains(string(info), volumeGroupName)
395401
}
396402

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

+4
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)