k3s-io/k3s · error

validation failed for toleration %d: %v

Error message

validation failed for toleration %d: %v

What it means

Error "validation failed for toleration %d: %v" thrown in k3s-io/k3s.

Source

Thrown at pkg/cloudprovider/servicelb.go:720

// getTolerations retrieves the tolerations from a service's annotations.
// It parses the tolerations from a JSON or YAML string stored in the annotations.
func (k *k3s) getTolerations(svc *core.Service) ([]core.Toleration, error) {
	tolerationsStr, ok := svc.Annotations[tolerationsAnnotation]
	if !ok {
		return []core.Toleration{}, nil
	}

	var tolerations []core.Toleration
	if err := json.Unmarshal([]byte(tolerationsStr), &tolerations); err != nil {
		if err := yaml.Unmarshal([]byte(tolerationsStr), &tolerations); err != nil {
			return nil, fmt.Errorf("failed to parse tolerations from annotation %s: %v", tolerationsAnnotation, err)
		}
	}

	for i := range tolerations {
		if err := validateToleration(&tolerations[i]); err != nil {
			return nil, fmt.Errorf("validation failed for toleration %d: %v", i, err)
		}
	}

	return tolerations, nil
}

// validateToleration ensures a toleration has valid fields according to its operator.
func validateToleration(toleration *core.Toleration) error {
	if toleration.Operator == "" {
		toleration.Operator = core.TolerationOpEqual
	}

	if toleration.Key == "" && toleration.Operator != core.TolerationOpExists {
		return errors.New("toleration with empty key must have operator 'Exists'")
	}

	if toleration.Operator == core.TolerationOpExists && toleration.Value != "" {
		return errors.New("toleration with operator 'Exists' must have an empty value")

View on GitHub (pinned to 6ba341e396)

When it happens

Trigger: Thrown at pkg/cloudprovider/servicelb.go:720 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of k3s-io/k3s@6ba341e396 (2026-08-15). Data as JSON: /api/errors/48bf22bf0b92e2f5. Report an issue: GitHub.