Skip to content

Commit c17d73e

Browse files
authored
Merge pull request #361 from davidz627/fix/maxLimits
Amend volume limits returned by the driver to documented-1 since node…
2 parents c782884 + ee3df05 commit c17d73e

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
@@ -47,11 +47,14 @@ type GCENodeServer struct {
4747
var _ csi.NodeServer = &GCENodeServer{}
4848

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

5760
func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
@@ -442,9 +445,9 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
442445
// Machine-type format: n1-type-CPUS or custom-CPUS-RAM or f1/g1-type
443446
machineType := ns.MetadataService.GetMachineType()
444447
if strings.HasPrefix(machineType, "n1-") || strings.HasPrefix(machineType, "custom-") {
445-
volumeLimits = volumeLimit128
448+
volumeLimits = volumeLimitBig
446449
} else {
447-
volumeLimits = volumeLimit16
450+
volumeLimits = volumeLimitSmall
448451
}
449452
return volumeLimits, nil
450453
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,27 @@ func TestNodeGetVolumeLimits(t *testing.T) {
7474
{
7575
name: "Predifined standard machine",
7676
machineType: "n1-standard-1",
77-
expVolumeLimit: volumeLimit128,
77+
expVolumeLimit: volumeLimitBig,
7878
},
7979
{
8080
name: "Predifined micro machine",
8181
machineType: "f1-micro",
82-
expVolumeLimit: volumeLimit16,
82+
expVolumeLimit: volumeLimitSmall,
8383
},
8484
{
8585
name: "Predifined small machine",
8686
machineType: "g1-small",
87-
expVolumeLimit: volumeLimit16,
87+
expVolumeLimit: volumeLimitSmall,
8888
},
8989
{
9090
name: "Custom machine with 1GiB Mem",
9191
machineType: "custom-1-1024",
92-
expVolumeLimit: volumeLimit128,
92+
expVolumeLimit: volumeLimitBig,
9393
},
9494
{
9595
name: "Custom machine with 4GiB Mem",
9696
machineType: "custom-2-4096",
97-
expVolumeLimit: volumeLimit128,
97+
expVolumeLimit: volumeLimitBig,
9898
},
9999
}
100100

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)