Skip to content

Amend volume limits returned by the driver to documented-1 since node… #361

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
merged 1 commit into from
Aug 2, 2019
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
15 changes: 9 additions & 6 deletions pkg/gce-pd-csi-driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ type GCENodeServer struct {
var _ csi.NodeServer = &GCENodeServer{}

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

func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
Expand Down Expand Up @@ -442,9 +445,9 @@ func (ns *GCENodeServer) GetVolumeLimits() (int64, error) {
// Machine-type format: n1-type-CPUS or custom-CPUS-RAM or f1/g1-type
machineType := ns.MetadataService.GetMachineType()
if strings.HasPrefix(machineType, "n1-") || strings.HasPrefix(machineType, "custom-") {
volumeLimits = volumeLimit128
volumeLimits = volumeLimitBig
} else {
volumeLimits = volumeLimit16
volumeLimits = volumeLimitSmall
}
return volumeLimits, nil
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/gce-pd-csi-driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ func TestNodeGetVolumeLimits(t *testing.T) {
{
name: "Predifined standard machine",
machineType: "n1-standard-1",
expVolumeLimit: volumeLimit128,
expVolumeLimit: volumeLimitBig,
},
{
name: "Predifined micro machine",
machineType: "f1-micro",
expVolumeLimit: volumeLimit16,
expVolumeLimit: volumeLimitSmall,
},
{
name: "Predifined small machine",
machineType: "g1-small",
expVolumeLimit: volumeLimit16,
expVolumeLimit: volumeLimitSmall,
},
{
name: "Custom machine with 1GiB Mem",
machineType: "custom-1-1024",
expVolumeLimit: volumeLimit128,
expVolumeLimit: volumeLimitBig,
},
{
name: "Custom machine with 4GiB Mem",
machineType: "custom-2-4096",
expVolumeLimit: volumeLimit128,
expVolumeLimit: volumeLimitBig,
},
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/single_zone_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
readyState = "READY"
standardDiskType = "pd-standard"
ssdDiskType = "pd-ssd"
defaultVolumeLimit int64 = 128
defaultVolumeLimit int64 = 127
)

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