mirror of https://github.com/kubernetes/kops.git
Limit GCE tag for role to 63 chars
This commit is contained in:
parent
3310db3447
commit
ccf31f7491
|
|
@ -67,5 +67,5 @@ func DecodeGCELabel(s string) (string, error) {
|
||||||
|
|
||||||
// TagForRole return the instance (network) tag used for instances with the given role.
|
// TagForRole return the instance (network) tag used for instances with the given role.
|
||||||
func TagForRole(clusterName string, role kops.InstanceGroupRole) string {
|
func TagForRole(clusterName string, role kops.InstanceGroupRole) string {
|
||||||
return SafeClusterName(clusterName) + "-" + GceLabelNameRolePrefix + strings.ToLower(string(role))
|
return ClusterPrefixedName(GceLabelNameRolePrefix+strings.ToLower(string(role)), clusterName, 63)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,24 @@ func IsNotReady(err error) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClusterPrefixedName returns a cluster-prefixed name, with a maxLength
|
||||||
|
func ClusterPrefixedName(objectName string, clusterName string, maxLength int) string {
|
||||||
|
suffix := "-" + objectName
|
||||||
|
suffixLength := maxLength - len(suffix)
|
||||||
|
|
||||||
|
// GCE does not support . in tags / names
|
||||||
|
safeClusterName := strings.Replace(clusterName, ".", "-", -1)
|
||||||
|
|
||||||
|
opt := truncate.TruncateStringOptions{
|
||||||
|
MaxLength: suffixLength,
|
||||||
|
AlwaysAddHash: false,
|
||||||
|
HashLength: 6,
|
||||||
|
}
|
||||||
|
prefix := truncate.TruncateString(safeClusterName, opt)
|
||||||
|
|
||||||
|
return prefix + suffix
|
||||||
|
}
|
||||||
|
|
||||||
// ClusterSuffixedName returns a cluster-suffixed name, with a maxLength
|
// ClusterSuffixedName returns a cluster-suffixed name, with a maxLength
|
||||||
func ClusterSuffixedName(objectName string, clusterName string, maxLength int) (string, error) {
|
func ClusterSuffixedName(objectName string, clusterName string, maxLength int) (string, error) {
|
||||||
prefix := objectName + "-"
|
prefix := objectName + "-"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue