mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #100404 from gnufied/reduce-vsphere-volume-length
reduce volume length for vsphere volumes
This commit is contained in:
commit
67820edf18
@ -25,7 +25,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
cloudprovider "k8s.io/cloud-provider"
|
cloudprovider "k8s.io/cloud-provider"
|
||||||
volumehelpers "k8s.io/cloud-provider/volume/helpers"
|
volumehelpers "k8s.io/cloud-provider/volume/helpers"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@ -67,6 +67,15 @@ const (
|
|||||||
ObjectSpaceReservationCapabilityMin = 0
|
ObjectSpaceReservationCapabilityMin = 0
|
||||||
ObjectSpaceReservationCapabilityMax = 100
|
ObjectSpaceReservationCapabilityMax = 100
|
||||||
IopsLimitCapabilityMin = 0
|
IopsLimitCapabilityMin = 0
|
||||||
|
// reduce number of characters in vsphere volume name. The reason for setting length smaller than 255 is because typically
|
||||||
|
// volume name also becomes part of mount path - /var/lib/kubelet/plugins/kubernetes.io/vsphere-volume/mounts/<name>
|
||||||
|
// and systemd has a limit of 256 chars in a unit name - https://github.com/systemd/systemd/pull/14294
|
||||||
|
// so if we subtract the kubelet path prefix from 256, we are left with 191 characters.
|
||||||
|
// Since datastore name is typically part of volumeName we are choosing a shorter length of 63
|
||||||
|
// and leaving room of certain characters being escaped etc.
|
||||||
|
// Given that volume name is typically of the form - pvc-0f13e3ad-97f8-41ab-9392-84562ef40d17.vmdk (45 chars),
|
||||||
|
// this should still leave plenty of room for clusterName inclusion.
|
||||||
|
maxVolumeLength = 63
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrProbeVolume = errors.New("error scanning attached volumes")
|
var ErrProbeVolume = errors.New("error scanning attached volumes")
|
||||||
@ -97,13 +106,7 @@ func (util *VsphereDiskUtil) CreateVolume(v *vsphereVolumeProvisioner, selectedN
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
volSizeKiB := volSizeMiB * 1024
|
volSizeKiB := volSizeMiB * 1024
|
||||||
// reduce number of characters in vsphere volume name. The reason for setting length smaller than 255 is because typically
|
name := volumeutil.GenerateVolumeName(v.options.ClusterName, v.options.PVName, maxVolumeLength)
|
||||||
// volume name also becomes part of mount path - /var/lib/kubelet/plugins/kubernetes.io/vsphere-volume/mounts/<name>
|
|
||||||
// and systemd has a limit of 256 chars in a unit name - https://github.com/systemd/systemd/pull/14294
|
|
||||||
// so if we subtract the kubelet path prefix from 256, we are left with 191 characters.
|
|
||||||
// Since datastore name is typically part of volumeName we are choosing a shorter length of 90
|
|
||||||
// and leaving room of certain characters being escaped etc.
|
|
||||||
name := volumeutil.GenerateVolumeName(v.options.ClusterName, v.options.PVName, 90)
|
|
||||||
volumeOptions := &vclib.VolumeOptions{
|
volumeOptions := &vclib.VolumeOptions{
|
||||||
CapacityKB: volSizeKiB,
|
CapacityKB: volSizeKiB,
|
||||||
Tags: *v.options.CloudTags,
|
Tags: *v.options.CloudTags,
|
||||||
|
Loading…
Reference in New Issue
Block a user