Skip to content

Commit a555825

Browse files
authored
Merge pull request kubernetes#88602 from yuga711/pd-limit
Fix to expose max gce-pd disks per instance
2 parents 0bd6940 + 505dff6 commit a555825

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pkg/volume/gcepd/gce_pd.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"path/filepath"
2626
"runtime"
2727
"strconv"
28-
"strings"
2928

3029
"k8s.io/klog"
3130
"k8s.io/utils/mount"
@@ -65,13 +64,13 @@ const (
6564

6665
// The constants are used to map from the machine type (number of CPUs) to the limit of
6766
// persistent disks that can be attached to an instance. Please refer to gcloud doc
68-
// https://cloud.google.com/compute/docs/disks/#increased_persistent_disk_limits
67+
// https://cloud.google.com/compute/docs/machine-types
6968
// These constants are all the documented attach limit minus one because the
7069
// node boot disk is considered an attachable disk so effective attach limit is
7170
// one less.
7271
const (
7372
volumeLimitSmall = 15
74-
VolumeLimitBig = 127
73+
volumeLimitBig = 127
7574
)
7675

7776
func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
@@ -149,12 +148,14 @@ func (plugin *gcePersistentDiskPlugin) GetVolumeLimits() (map[string]int64, erro
149148
klog.Errorf("Failed to get instance type from GCE cloud provider")
150149
return volumeLimits, nil
151150
}
152-
if strings.HasPrefix(instanceType, "n1-") || strings.HasPrefix(instanceType, "custom-") {
153-
volumeLimits[util.GCEVolumeLimitKey] = VolumeLimitBig
154-
} else {
155-
volumeLimits[util.GCEVolumeLimitKey] = volumeLimitSmall
151+
smallMachineTypes := []string{"f1-micro", "g1-small", "e2-micro", "e2-small", "e2-medium"}
152+
for _, small := range smallMachineTypes {
153+
if instanceType == small {
154+
volumeLimits[util.GCEVolumeLimitKey] = volumeLimitSmall
155+
return volumeLimits, nil
156+
}
156157
}
157-
158+
volumeLimits[util.GCEVolumeLimitKey] = volumeLimitBig
158159
return volumeLimits, nil
159160
}
160161

0 commit comments

Comments
 (0)