mirror of https://github.com/k3s-io/k3s
Move LabelMultiZoneDelimiter to pkg/volume/util
Change-Id: I098b210e44ac3bb1901e029ff7cd33aa0afbdc74pull/564/head
parent
274c9976d2
commit
cf44bfa556
|
@ -26,6 +26,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
||||||
|
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
@ -283,7 +284,7 @@ func createPVSpec(name string, readOnly bool, zones []string) *volume.Spec {
|
||||||
}
|
}
|
||||||
|
|
||||||
if zones != nil {
|
if zones != nil {
|
||||||
zonesLabel := strings.Join(zones, v1.LabelMultiZoneDelimiter)
|
zonesLabel := strings.Join(zones, volumeutil.LabelMultiZoneDelimiter)
|
||||||
spec.PersistentVolume.ObjectMeta.Labels = map[string]string{
|
spec.PersistentVolume.ObjectMeta.Labels = map[string]string{
|
||||||
v1.LabelZoneFailureDomain: zonesLabel,
|
v1.LabelZoneFailureDomain: zonesLabel,
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ func udevadmChangeToDrive(drivePath string) error {
|
||||||
func isRegionalPD(spec *volume.Spec) bool {
|
func isRegionalPD(spec *volume.Spec) bool {
|
||||||
if spec.PersistentVolume != nil {
|
if spec.PersistentVolume != nil {
|
||||||
zonesLabel := spec.PersistentVolume.Labels[v1.LabelZoneFailureDomain]
|
zonesLabel := spec.PersistentVolume.Labels[v1.LabelZoneFailureDomain]
|
||||||
zones := strings.Split(zonesLabel, v1.LabelMultiZoneDelimiter)
|
zones := strings.Split(zonesLabel, volumeutil.LabelMultiZoneDelimiter)
|
||||||
return len(zones) > 1
|
return len(zones) > 1
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -73,6 +73,9 @@ const (
|
||||||
// VolumeDynamicallyCreatedByKey is the key of the annotation on PersistentVolume
|
// VolumeDynamicallyCreatedByKey is the key of the annotation on PersistentVolume
|
||||||
// object created dynamically
|
// object created dynamically
|
||||||
VolumeDynamicallyCreatedByKey = "kubernetes.io/createdby"
|
VolumeDynamicallyCreatedByKey = "kubernetes.io/createdby"
|
||||||
|
|
||||||
|
// LabelMultiZoneDelimiter separates zones for volumes
|
||||||
|
LabelMultiZoneDelimiter = "__"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VolumeZoneConfig contains config information about zonal volume.
|
// VolumeZoneConfig contains config information about zonal volume.
|
||||||
|
@ -329,7 +332,7 @@ func ZonesFromAllowedTopologies(allowedTopologies []v1.TopologySelectorTerm) (se
|
||||||
|
|
||||||
// ZonesSetToLabelValue converts zones set to label value
|
// ZonesSetToLabelValue converts zones set to label value
|
||||||
func ZonesSetToLabelValue(strSet sets.String) string {
|
func ZonesSetToLabelValue(strSet sets.String) string {
|
||||||
return strings.Join(strSet.UnsortedList(), v1.LabelMultiZoneDelimiter)
|
return strings.Join(strSet.UnsortedList(), LabelMultiZoneDelimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZonesToSet converts a string containing a comma separated list of zones to set
|
// ZonesToSet converts a string containing a comma separated list of zones to set
|
||||||
|
@ -343,7 +346,7 @@ func ZonesToSet(zonesString string) (sets.String, error) {
|
||||||
|
|
||||||
// LabelZonesToSet converts a PV label value from string containing a delimited list of zones to set
|
// LabelZonesToSet converts a PV label value from string containing a delimited list of zones to set
|
||||||
func LabelZonesToSet(labelZonesValue string) (sets.String, error) {
|
func LabelZonesToSet(labelZonesValue string) (sets.String, error) {
|
||||||
return stringToSet(labelZonesValue, v1.LabelMultiZoneDelimiter)
|
return stringToSet(labelZonesValue, LabelMultiZoneDelimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StringToSet converts a string containing list separated by specified delimiter to a set
|
// StringToSet converts a string containing list separated by specified delimiter to a set
|
||||||
|
@ -365,7 +368,7 @@ func stringToSet(str, delimiter string) (sets.String, error) {
|
||||||
|
|
||||||
// LabelZonesToList converts a PV label value from string containing a delimited list of zones to list
|
// LabelZonesToList converts a PV label value from string containing a delimited list of zones to list
|
||||||
func LabelZonesToList(labelZonesValue string) ([]string, error) {
|
func LabelZonesToList(labelZonesValue string) ([]string, error) {
|
||||||
return stringToList(labelZonesValue, v1.LabelMultiZoneDelimiter)
|
return stringToList(labelZonesValue, LabelMultiZoneDelimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StringToList converts a string containing list separated by specified delimiter to a list
|
// StringToList converts a string containing list separated by specified delimiter to a list
|
||||||
|
|
|
@ -17,10 +17,9 @@ limitations under the License.
|
||||||
package v1
|
package v1
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LabelHostname = "kubernetes.io/hostname"
|
LabelHostname = "kubernetes.io/hostname"
|
||||||
LabelZoneFailureDomain = "failure-domain.beta.kubernetes.io/zone"
|
LabelZoneFailureDomain = "failure-domain.beta.kubernetes.io/zone"
|
||||||
LabelMultiZoneDelimiter = "__"
|
LabelZoneRegion = "failure-domain.beta.kubernetes.io/region"
|
||||||
LabelZoneRegion = "failure-domain.beta.kubernetes.io/region"
|
|
||||||
|
|
||||||
LabelInstanceType = "beta.kubernetes.io/instance-type"
|
LabelInstanceType = "beta.kubernetes.io/instance-type"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue