{"record":{"id":"6ff85be3dd0e1ef6","repo":"kubernetes/kops","slug":"failed-to-configure-pruning-for-s-w","errorCode":null,"errorMessage":"failed to configure pruning for %s: %w","messagePattern":"failed to configure pruning for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest.go","lineNumber":108,"sourceCode":"\t\tmanifestBytes, err = a.addonRenderer.RenderTemplate(fi.ValueOf(a.Location), manifestBytes, tasksVisibleToAddons(c.AllTasks()))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error rendering addon %q template: %w\", fi.ValueOf(a.Name), err)\n\t\t}\n\t}\n\n\tif !a.skipRemap {\n\t\tmanifestBytes, err = addonmanifests.RemapAddonManifest(a.addonSpec, a.modelContext, a.assetBuilder, manifestBytes, a.serviceAccounts)\n\t\tif err != nil {\n\t\t\tklog.Infof(\"invalid manifest: %s\", string(manifestBytes))\n\t\t\treturn fmt.Errorf(\"error remapping manifest %s: %v\", fi.ValueOf(a.Location), err)\n\t\t}\n\t}\n\n\tmanifestBytes = []byte(strings.TrimSpace(string(manifestBytes)))\n\n\tif a.buildPrune {\n\t\tif err := buildPruneDirectives(a.addonSpec, manifestBytes); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to configure pruning for %s: %w\", fi.ValueOf(a.addonSpec.Name), err)\n\t\t}\n\t}\n\n\trawManifest := string(manifestBytes)\n\tmanifestHash, err := utils.HashString(rawManifest)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error hashing manifest: %v\", err)\n\t}\n\ta.addonSpec.ManifestHash = manifestHash\n\ta.Contents = fi.NewBytesResource(manifestBytes)\n\n\treturn nil\n}\n\n// Find returns a sparsely-populated AddonManifest reflecting the stored ManagedFile: only the\n// fields needed by CheckChanges/Render/RenderTerraform (which delegate to toManagedFile) are set.\n// Render-only fields such as addonSpec and source are intentionally left nil since they have no\n// meaning for an already-materialized remote file.","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest.go#L90-L126","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped (%w) cause to see exactly what buildPruneDirectives rejected","Ensure the addon manifest contains the expected pruning metadata (selectors/labels identifying the addon's resources)","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","If pruning is not needed for this addon, construct the AddonManifest with buildPrune=false"],"exampleFix":"// before\nm := &AddonManifest{ ..., addonSpec: spec, buildPrune: true } // spec.Name nil\n// after\nspec.Name = fi.PtrTo(\"my-addon.addons.k8s.io\")\nm := &AddonManifest{ ..., addonSpec: spec, buildPrune: true }","handlingStrategy":"validation","validationCode":"if m.buildPrune {\n    if m.addonSpec == nil || m.addonSpec.Name == nil || *m.addonSpec.Name == \"\" {\n        return fmt.Errorf(\"buildPrune requires a named addonSpec\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable buildPrune for addons using the standard kOps manifest layout with proper labels","Always set addonSpec.Name before enabling pruning","Check the wrapped buildPruneDirectives error to learn the exact missing metadata"],"tags":["addons","pruning","bootstrap-channel"],"backgroundTag":"prune-configuration-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}