cilium/cilium · error

must not be more than %d characters

Error message

must not be more than %d characters

What it means

ValidateClusterName enforces the cluster naming rules: at most 32 characters, lower-case alphanumerics and '-', starting and ending with an alphanumeric character (DNS-label-like rules required for Kubernetes resource names and clustermesh identity). This specific error fires when the name exceeds the 32-character limit.

Source

Thrown at pkg/clustermesh/types/types.go:72

	if clusterID == ClusterIDMin {
		return fmt.Errorf("ClusterID %d is reserved", ClusterIDMin)
	}

	if clusterID > ClusterIDMax {
		return fmt.Errorf("ClusterID > %d is not supported", ClusterIDMax)
	}

	return nil
}

// ValidateClusterName validates that the given name matches the cluster name specifications.
func ValidateClusterName(name string) error {
	if name == "" {
		return errors.New("must not be empty")
	}

	if len(name) > clusterNameMaxLength {
		return fmt.Errorf("must not be more than %d characters", clusterNameMaxLength)
	}

	if !clusterNameRegex.MatchString(name) {
		return errors.New("must consist of lower case alphanumeric characters and '-', and must start and end with an alphanumeric character")
	}

	return nil
}

func RegisterClusterInfoValidator(lc cell.Lifecycle, cinfo ClusterInfo) {
	lc.Append(cell.Hook{
		OnStart: func(cell.HookContext) error {
			if err := cinfo.InitClusterIDMax(); err != nil {
				return err
			}
			if err := cinfo.ValidateStrict(); err != nil {
				return err
			}

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Shorten the cluster name to 32 characters or fewer (use a short alias)
  2. Keep the long name as infrastructure metadata and pass a short sanitized name to --cluster-name
  3. Trim/replace hyphen runs when deriving the name from FQDNs before validation

Example fix

// before
--cluster-name=mycompany-production-us-east-1-eks-main
// after
--cluster-name=prod-use1-main
Defensive patterns

Strategy: validation

Validate before calling

const maxLen = 32
var nameRe = regexp.MustCompile(`^([a-z0-9][-a-z0-9]*)?[a-z0-9]$`)
func validateNamePre(name string) error {
    if name == "" { return errors.New("cluster name must not be empty") }
    if len(name) > maxLen { return fmt.Errorf("cluster name must be at most %d characters", maxLen) }
    if !nameRe.MatchString(name) { return errors.New("cluster name must be lowercase alphanumeric/-, starting and ending alphanumeric") }
    return nil
}

Type guard

func isValidClusterName(s string) bool {
    return s != "" && len(s) <= 32 && nameRe.MatchString(s)
}

Try / catch

if err := types.ValidateClusterName(name); err != nil {
    return fmt.Errorf("invalid --cluster-name %q: %w", name, err)
}

Prevention

When it happens

Trigger: Calling ValidateClusterName() (directly, or via validateName/Validate/ValidateStrict) with a name whose byte length is > clusterNameMaxLength (32).

Common situations: Using a long cloud-provider-generated name (e.g. a full EKS/GKE cluster ARN or long environment-prefixed name) as --cluster-name.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/4291f1959a556596. Report an issue: GitHub.