kubernetes/kubernetes · warning

failed to parse annotation[%s]=%s as int64: %v

Error message

failed to parse annotation[%s]=%s as int64: %v

What it means

Convert_v1_Deployment_To_apps_Deployment reads the deprecated 'deployment.kubernetes.io/revision' annotation (DeprecatedRollbackTo) and parses it as an int64 to populate the internal RollbackTo field for round-trip conversion. This error fires when the annotation value is present but not a valid base-10 integer. It preserves legacy rollback semantics during conversion between external and internal types.

Source

Thrown at pkg/apis/apps/v1/conversion.go:48

// Convert_apps_DeploymentSpec_To_v1_DeploymentSpec is defined here, because public
// conversion is not auto-generated due to existing warnings.
func Convert_apps_DeploymentSpec_To_v1_DeploymentSpec(in *apps.DeploymentSpec, out *appsv1.DeploymentSpec, s conversion.Scope) error {
	if err := autoConvert_apps_DeploymentSpec_To_v1_DeploymentSpec(in, out, s); err != nil {
		return err
	}
	return nil
}

func Convert_v1_Deployment_To_apps_Deployment(in *appsv1.Deployment, out *apps.Deployment, s conversion.Scope) error {
	if err := autoConvert_v1_Deployment_To_apps_Deployment(in, out, s); err != nil {
		return err
	}

	// Copy annotation to deprecated rollbackTo field for roundtrip
	// TODO: remove this conversion after we delete extensions/v1beta1 and apps/v1beta1 Deployment
	if revision := in.Annotations[appsv1.DeprecatedRollbackTo]; revision != "" {
		if revision64, err := strconv.ParseInt(revision, 10, 64); err != nil {
			return fmt.Errorf("failed to parse annotation[%s]=%s as int64: %v", appsv1.DeprecatedRollbackTo, revision, err)
		} else {
			out.Spec.RollbackTo = new(apps.RollbackConfig)
			out.Spec.RollbackTo.Revision = revision64
		}
		out.Annotations = deepCopyStringMap(out.Annotations)
		delete(out.Annotations, appsv1.DeprecatedRollbackTo)
	} else {
		out.Spec.RollbackTo = nil
	}

	return nil
}

func Convert_apps_Deployment_To_v1_Deployment(in *apps.Deployment, out *appsv1.Deployment, s conversion.Scope) error {
	if err := autoConvert_apps_Deployment_To_v1_Deployment(in, out, s); err != nil {
		return err
	}

View on GitHub (pinned to b882c60b40)

Solutions

  1. Remove or correct the DeprecatedRollbackTo annotation so its value is a base-10 integer (the revision number) or empty.
  2. If rollback is not intended, delete the annotation entirely: `kubectl annotate deployment <name> deployment.kubernetes.io/revision-`.
  3. Patch the object with a valid revision integer if rollback semantics are needed.
  4. Avoid writing this deprecated annotation in automation; it exists only for legacy round-trip compatibility.

Example fix

// before: annotation set to a non-numeric value
annotations["deployment.kubernetes.io/revision"] = "v2"
// after: valid integer revision or omit entirely
annotations["deployment.kubernetes.io/revision"] = "2"
// or remove it
delete(annotations, "deployment.kubernetes.io/revision")
Defensive patterns

Strategy: validation

Validate before calling

// Strip or validate the DeprecatedRollbackTo annotation before conversion
if v, ok := annotations[appsv1.DeprecatedRollbackTo]; ok {
    if _, err := strconv.ParseInt(v, 10, 64); err != nil {
        delete(annotations, appsv1.DeprecatedRollbackTo) // or fix the value
    }
}

Type guard

func hasValidRollbackAnnotation(annotations map[string]string) bool {
    v, ok := annotations["deployment.kubernetes.io/revision"]
    if !ok || v == "" { return true }
    _, err := strconv.ParseInt(v, 10, 64)
    return err == nil
}

Try / catch

if err := scheme.Convert(in, out, nil); err != nil {
    if strings.Contains(err.Error(), "failed to parse annotation") { /* fix/remove annotation and retry */ }
}

Prevention

When it happens

Trigger: A Deployment object carries the DeprecatedRollbackTo annotation with a non-numeric value, and a conversion from the external apps/v1 Deployment to the internal apps Deployment is performed (e.g. via the API server's scheme.Convert, kubectl, or any controller reading the object through the scheme).

Common situations: Manual annotation injection with a typo or a hash string instead of a revision number; a tool writing a semantic value (e.g. 'latest') into the annotation; stale objects from before the deprecation that got corrupted; migration scripts setting annotations incorrectly.

Understand the failure class

Related errors


AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07). Data as JSON: /api/errors/f350608df08d5848. Report an issue: GitHub.