Skip to content

Commit 837784b

Browse files
committed
Amend volume limits returned by the driver to documented-1 since node boot disk is attachable disk
1 parent 79bf1df commit 837784b

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ type GCENodeServer struct {
4444
var _ csi.NodeServer = &GCENodeServer{}
4545

4646
// The constants are used to map from the machine type to the limit of
47-
// persistent disks that can be attached to an instance. Please refer to gcloud doc
48-
// https://cloud.google.com/compute/docs/disks/#pdnumberlimits
47+
// persistent disks that can be attached to an instance. Please refer to gcloud
48+
// doc https://cloud.google.com/compute/docs/disks/#pdnumberlimits
49+
// These constants are all the documented attach limit minus one because the
50+
// node boot disk is considered an attachable disk so effective attach limit is
51+
// one less.
4952
const (
50-
volumeLimit16 int64 = 16
51-
volumeLimit128 int64 = 128
53+
volumeLimitSmall int64 = 15
54+
volumeLimitBig int64 = 127
5255
)
5356

5457
func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
@@ -327,9 +330,9 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
327330
// Machine-type format: n1-type-CPUS or custom-CPUS-RAM or f1/g1-type
328331
machineType := ns.MetadataService.GetMachineType()
329332
if strings.HasPrefix(machineType, "n1-") || strings.HasPrefix(machineType, "custom-") {
330-
volumeLimits = volumeLimit128
333+
volumeLimits = volumeLimitBig
331334
} else {
332-
volumeLimits = volumeLimit16
335+
volumeLimits = volumeLimitSmall
333336
}
334337
return volumeLimits, nil
335338
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,27 @@ func TestNodeGetVolumeLimits(t *testing.T) {
5252
{
5353
name: "Predifined standard machine",
5454
machineType: "n1-standard-1",
55-
expVolumeLimit: volumeLimit128,
55+
expVolumeLimit: volumeLimitBig,
5656
},
5757
{
5858
name: "Predifined micro machine",
5959
machineType: "f1-micro",
60-
expVolumeLimit: volumeLimit16,
60+
expVolumeLimit: volumeLimitSmall,
6161
},
6262
{
6363
name: "Predifined small machine",
6464
machineType: "g1-small",
65-
expVolumeLimit: volumeLimit16,
65+
expVolumeLimit: volumeLimitSmall,
6666
},
6767
{
6868
name: "Custom machine with 1GiB Mem",
6969
machineType: "custom-1-1024",
70-
expVolumeLimit: volumeLimit128,
70+
expVolumeLimit: volumeLimitBig,
7171
},
7272
{
7373
name: "Custom machine with 4GiB Mem",
7474
machineType: "custom-2-4096",
75-
expVolumeLimit: volumeLimit128,
75+
expVolumeLimit: volumeLimitBig,
7676
},
7777
}
7878

test/e2e/tests/single_zone_e2e_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
readyState = "READY"
4343
standardDiskType = "pd-standard"
4444
ssdDiskType = "pd-ssd"
45-
defaultVolumeLimit int64 = 128
45+
defaultVolumeLimit int64 = 127
4646
)
4747

4848
var _ = Describe("GCE PD CSI Driver", func() {

0 commit comments

Comments
 (0)