mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Fix partition for 0 partitions defaulting
This commit is contained in:
parent
feb0937fa4
commit
e59f261c12
@ -87,13 +87,19 @@ func (g *gcePersistentDiskCSITranslator) TranslateInTreePVToCSI(pv *v1.Persisten
|
|||||||
}
|
}
|
||||||
|
|
||||||
gceSource := pv.Spec.PersistentVolumeSource.GCEPersistentDisk
|
gceSource := pv.Spec.PersistentVolumeSource.GCEPersistentDisk
|
||||||
|
|
||||||
|
partition := ""
|
||||||
|
if gceSource.Partition != 0 {
|
||||||
|
partition = strconv.Itoa(int(gceSource.Partition))
|
||||||
|
}
|
||||||
|
|
||||||
csiSource := &v1.CSIPersistentVolumeSource{
|
csiSource := &v1.CSIPersistentVolumeSource{
|
||||||
Driver: GCEPDDriverName,
|
Driver: GCEPDDriverName,
|
||||||
VolumeHandle: volID,
|
VolumeHandle: volID,
|
||||||
ReadOnly: gceSource.ReadOnly,
|
ReadOnly: gceSource.ReadOnly,
|
||||||
FSType: gceSource.FSType,
|
FSType: gceSource.FSType,
|
||||||
VolumeAttributes: map[string]string{
|
VolumeAttributes: map[string]string{
|
||||||
"partition": strconv.FormatInt(int64(gceSource.Partition), 10),
|
"partition": partition,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +127,7 @@ func (g *gcePersistentDiskCSITranslator) TranslateCSIPVToInTree(pv *v1.Persisten
|
|||||||
FSType: csiSource.FSType,
|
FSType: csiSource.FSType,
|
||||||
ReadOnly: csiSource.ReadOnly,
|
ReadOnly: csiSource.ReadOnly,
|
||||||
}
|
}
|
||||||
if partition, ok := csiSource.VolumeAttributes["partition"]; ok {
|
if partition, ok := csiSource.VolumeAttributes["partition"]; ok && partition != "" {
|
||||||
partInt, err := strconv.Atoi(partition)
|
partInt, err := strconv.Atoi(partition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to convert partition %v to integer: %v", partition, err)
|
return nil, fmt.Errorf("Failed to convert partition %v to integer: %v", partition, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user