kubernetes/kops · error
error visiting containers: %w
Error message
error visiting containers: %w
What it means
After computing new args for an externally provided cloud-controller-manager addon, buildAddons walks the manifest containers with addon.VisitContainers to inject the args. This error wraps any failure from VisitContainers, typically a malformed manifest structure that cannot be traversed.
Source
Thrown at upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannelbuilder.go:931
gkDaemonset := schema.GroupKind{Group: "apps", Kind: "DaemonSet"}
for _, addon := range b.ClusterAddons {
if addon.GroupVersionKind().GroupKind() == gkDaemonset &&
addon.GetName() == "cloud-controller-manager" &&
addon.GetNamespace() == "kube-system" {
klog.Infof("replacing arguments in externally provided cloud-controller-manager")
args, err := b.addonRenderer.CloudControllerConfigArgv()
if err != nil {
return nil, nil, fmt.Errorf("in TemplateFunction CloudControllerConfigArgv: %w", err)
}
if err := addon.VisitContainers(func(container map[string]interface{}) error {
// TODO: Check name?
container["args"] = args
return nil
}); err != nil {
return nil, nil, fmt.Errorf("error visiting containers: %w", err)
}
}
}
}
if useBuiltin {
id := "k8s-1.23"
location := key + "/" + id + ".yaml"
addon := addons.Add(&channelsapi.AddonSpec{
Name: new(key),
Manifest: new(location),
Selector: map[string]string{"k8s-addon": key},
Id: id,
})
addon.BuildPrune = true
}
}
}View on GitHub (pinned to 4c8573c808)
Solutions
- Validate the CCM addon manifest is a standard Deployment/DaemonSet with containers
- Fix or regenerate the addon manifest from upstream
- Remove the external addon to fall back to kops builtin CCM
- Compare the manifest with the structure kops expects (spec.template.spec.containers)
Example fix
// before: nonstandard manifest
kind: Pod
spec:
containers: []
// after: standard workload shape
kind: DaemonSet
spec:
template:
spec:
containers:
- name: ccm Defensive patterns
Strategy: validation
Validate before calling
// Ensure the manifest has a traversable pod template before VisitContainers
var addon struct { Spec struct { Template struct { Spec struct { Containers []map[string]interface{} `json:"containers"` } `json:"spec"` } `json:"template"` } `json:"spec"` }
if err := yaml.Unmarshal(manifestBytes, &addon); err != nil || len(addon.Spec.Template.Spec.Containers) == 0 {
return errors.New("CCM manifest lacks spec.template.spec.containers")
} Try / catch
if err := addon.VisitContainers(setArgs); err != nil {
return fmt.Errorf("manifest not walkable; regenerate CCM manifest: %w", err)
} Prevention
- Use upstream CCM manifests as the base for edits
- Keep workload kinds standard (Deployment/DaemonSet)
- Validate manifests with kubectl before adding to a channel
When it happens
Trigger: Building a cluster with an external CCM addon whose manifest is not a valid Kubernetes pod-template structure (missing spec.template.spec.containers or unexpected shapes) causing VisitContainers to return an error.
Common situations: Hand-crafted or third-party CCM manifests with unusual structure; YAML that decodes but lacks expected container lists; addon channel drift after kops changes the expected schema.
Related errors
- unable to find manifest %s
- failed to parse manifest: %w
- error loading channel %q: %v
- unhandled kind %q in %s
- cannot specify additional objects when multiple clusters are
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/41afdd4ad9a8b448.
Report an issue: GitHub.