kubernetes/kops · error
error parsing Cluster %q: %v
Error message
error parsing Cluster %q: %v
What it means
fullClusterSpecs decodes the raw bytes of cluster-completed.spec with kopscodecs.Decode; if the payload is corrupt, in an unsupported version, or not valid serialized API data, the error is wrapped as 'error parsing Cluster %q: %v'. This is a deserialization failure, distinct from a read failure.
Source
Thrown at cmd/kops/get_cluster.go:297
return nil
}
func fullClusterSpecs(ctx context.Context, vfsContext *vfs.VFSContext, clusters []*kopsapi.Cluster) ([]*kopsapi.Cluster, error) {
var fullSpecs []*kopsapi.Cluster
for _, cluster := range clusters {
configBase, err := registry.ConfigBase(vfsContext, cluster)
if err != nil {
return nil, fmt.Errorf("error reading full cluster spec for %q: %v", cluster.ObjectMeta.Name, err)
}
configPath := configBase.Join(registry.PathClusterCompleted)
b, err := configPath.ReadFile(ctx)
if err != nil {
return nil, fmt.Errorf("error loading Cluster %q: %v", configPath, err)
}
o, _, err := kopscodecs.Decode(b, nil)
if err != nil {
return nil, fmt.Errorf("error parsing Cluster %q: %v", configPath, err)
}
if fullSpec, ok := o.(*kopsapi.Cluster); ok {
fullSpecs = append(fullSpecs, fullSpec)
} else {
return nil, fmt.Errorf("unexpected object type for Cluster %q: %T", configPath, o)
}
}
return fullSpecs, nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Use a kops binary version compatible with the cluster's kubernetesVersion/spec (check `kops version` vs the cluster's creation version).
- Inspect the raw object (`aws s3 cp ... -` or gsutil cat) for corruption or manual edits; restore it from backup or re-run `kops update cluster` to regenerate.
- Compare the apiVersion/kind in the stored spec against supported kops API versions for your binary.
- Never hand-edit state-store objects; edit via `kops edit cluster` instead.
Example fix
// before # spec stored with unsupported apiVersion after kops downgrade kops get cluster X --full # kops 1.19 binary vs cluster updated by 1.25 // after # upgrade the kops binary to match the cluster brew upgrade kops && kops get cluster X --full
Defensive patterns
Strategy: validation
Validate before calling
# sanity: kops binary version should match cluster creation version kv=$(kops version | grep -o '[0-9]*\.[0-9]*' | head -1) cv=$(kops get cluster "$CLUSTER" -o json | jq -r '.spec.kubernetesVersion') echo "kops=$kv k8s=$cv" # mismatched major versions can break decoding
Type guard
null
Try / catch
if ! kops get cluster "$CLUSTER" --full 2>err.txt; then
grep -q 'error parsing Cluster' err.txt && \
{ echo "spec corrupt or version mismatch; verify kops version vs cluster spec"; aws s3 cp ".../cluster-completed.spec" - ; }
fi Prevention
- Never hand-edit state-store objects; use `kops edit cluster` + `kops update cluster`.
- Keep the kops binary version aligned with the cluster's spec generation.
- Back up cluster-completed.spec before kops upgrades that rewrite API versions.
When it happens
Trigger: `kops get cluster X --full` where the stored spec was hand-edited, truncated by a failed upload, created by an incompatible kops version (codec/scheme mismatch), or otherwise not a decodable kops API object.
Common situations: Manual edits to state-store YAML introducing syntax errors; kops major-version skew between the binary and the cluster spec (e.g. old spec with retired API version); partially uploaded objects.
Related errors
- error marshaling yaml: %v
- error encoding object: %v
- error marshaling object: %v
- serializing completed cluster spec: %w
- error building annotation patch: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/b05954e02e1da019.
Report an issue: GitHub.