kubernetes/kops · error

failed to configure pruning for %s: %w

Error message

failed to configure pruning for %s: %w

What it means

When a.buildPrune is enabled, Normalize calls buildPruneDirectives(a.addonSpec, manifestBytes) to annotate the manifest with pruning directives derived from the addon spec. Any failure there is wrapped with %w as 'failed to configure pruning for <addon name>'. This prevents partially-prunable addons from being published to the bootstrap channel.

Source

Thrown at upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest.go:108

		manifestBytes, err = a.addonRenderer.RenderTemplate(fi.ValueOf(a.Location), manifestBytes, tasksVisibleToAddons(c.AllTasks()))
		if err != nil {
			return fmt.Errorf("error rendering addon %q template: %w", fi.ValueOf(a.Name), err)
		}
	}

	if !a.skipRemap {
		manifestBytes, err = addonmanifests.RemapAddonManifest(a.addonSpec, a.modelContext, a.assetBuilder, manifestBytes, a.serviceAccounts)
		if err != nil {
			klog.Infof("invalid manifest: %s", string(manifestBytes))
			return fmt.Errorf("error remapping manifest %s: %v", fi.ValueOf(a.Location), err)
		}
	}

	manifestBytes = []byte(strings.TrimSpace(string(manifestBytes)))

	if a.buildPrune {
		if err := buildPruneDirectives(a.addonSpec, manifestBytes); err != nil {
			return fmt.Errorf("failed to configure pruning for %s: %w", fi.ValueOf(a.addonSpec.Name), err)
		}
	}

	rawManifest := string(manifestBytes)
	manifestHash, err := utils.HashString(rawManifest)
	if err != nil {
		return fmt.Errorf("error hashing manifest: %v", err)
	}
	a.addonSpec.ManifestHash = manifestHash
	a.Contents = fi.NewBytesResource(manifestBytes)

	return nil
}

// Find returns a sparsely-populated AddonManifest reflecting the stored ManagedFile: only the
// fields needed by CheckChanges/Render/RenderTerraform (which delegate to toManagedFile) are set.
// Render-only fields such as addonSpec and source are intentionally left nil since they have no
// meaning for an already-materialized remote file.

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped (%w) cause to see exactly what buildPruneDirectives rejected
  2. Ensure the addon manifest contains the expected pruning metadata (selectors/labels identifying the addon's resources)
  3. Verify a.addonSpec.Name is set; the message uses fi.ValueOf(a.addonSpec.Name) and an empty name is a strong hint the spec is incomplete
  4. If pruning is not needed for this addon, construct the AddonManifest with buildPrune=false

Example fix

// before
m := &AddonManifest{ ..., addonSpec: spec, buildPrune: true } // spec.Name nil
// after
spec.Name = fi.PtrTo("my-addon.addons.k8s.io")
m := &AddonManifest{ ..., addonSpec: spec, buildPrune: true }
Defensive patterns

Strategy: validation

Validate before calling

if m.buildPrune {
    if m.addonSpec == nil || m.addonSpec.Name == nil || *m.addonSpec.Name == "" {
        return fmt.Errorf("buildPrune requires a named addonSpec")
    }
}

Prevention

When it happens

Trigger: Normalize runs with buildPrune=true and buildPruneDirectives returns an error — for example the manifest lacks the structure the prune builder expects (missing selectors/labels) or the addon spec name is unset/invalid for generating prune keys.

Common situations: A custom addon manifest without the labels/annotations buildPruneDirectives requires; an addon spec whose Name is empty so prune directives cannot be derived; a kOps version change in the prune-directive format for legacy manifests.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/6ff85be3dd0e1ef6. Report an issue: GitHub.