{"record":{"id":"6d97b260477a900c","repo":"kubernetes/kops","slug":"error-writing-additional-objects-v","errorCode":null,"errorMessage":"error writing additional objects: %v","messagePattern":"error writing additional objects: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create.go","lineNumber":229,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\n\t// Because not all addons support labels, we can only support one cluster here.\n\t// A single cluster per create is probably a good idea anyway.\n\tif len(addons) != 0 {\n\t\tif len(clusters) > 1 {\n\t\t\treturn fmt.Errorf(\"cannot specify additional objects when multiple clusters are created\")\n\t\t}\n\t\tif len(clusters) == 0 {\n\t\t\treturn fmt.Errorf(\"must specify a cluster when creating additional objects\")\n\t\t}\n\t\tcluster := clusters[0]\n\n\t\taddonsClient := clientset.AddonsFor(cluster)\n\n\t\tif err := addonsClient.Replace(addons); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing additional objects: %v\", err)\n\t\t}\n\t}\n\n\t{\n\t\t// If there is a value in this sb, this should mean that we have something to deploy\n\t\t// so let's advise the user how to engage the cloud provider and deploy\n\t\tif sb.String() != \"\" {\n\t\t\tfmt.Fprintf(&sb, \"\\n\")\n\t\t\tfmt.Fprintf(&sb, \"To deploy these resources, run: kops update cluster --name %s --yes\\n\", clusterName)\n\t\t\tfmt.Fprintf(&sb, \"\\n\")\n\t\t}\n\t\t_, err := out.Write(sb.Bytes())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error writing to output: %v\", err)\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create.go#L211-L247","documentation":"RunCreate wraps any error returned by the addons clientset's Replace call (which persists the addon objects in the cluster's state store) with 'error writing additional objects'. It means one or more of the user-supplied addon/additional objects could not be written to the backing store. The wrapped error from addonsClient.Replace is preserved as %v.","triggerScenarios":"Running `kops create -f` (or piping YAML) where the manifest contains addons; the AddonsFor(cluster).Replace() write to the state store fails — typically a state-store connection/permission problem or an invalid addon object rejected by the API.","commonSituations":"S3/GCS/OSS state store bucket misconfigured or unreachable; insufficient IAM credentials to write cluster state; malformed addon YAML that fails server-side validation.","solutions":["Read the wrapped %v error for the root cause and fix the underlying state-store access or object validity issue","Verify the --state flag / KOPS_STATE_STORE env var points to a writable bucket with valid credentials","Validate the addon YAML (kops create --dry-run) before applying","Retry the kops create command after resolving storage issues"],"exampleFix":"// before\nif err := addonsClient.Replace(addons); err != nil {\n\treturn fmt.Errorf(\"error writing additional objects: %v\", err)\n}\n// after\n// no code fix needed; fix state store access/creds so Replace succeeds","handlingStrategy":"try-catch","validationCode":"// verify state store access before create\nif os.Getenv(\"KOPS_STATE_STORE\") == \"\" {\n\treturn fmt.Errorf(\"KOPS_STATE_STORE must be set\")\n}\n// ensure credentials can write, e.g. aws s3 ls s3://$KOPS_STATE_STORE","typeGuard":null,"tryCatchPattern":"err := addonsClient.Replace(addons)\nif err != nil {\n\tvar e *StorageError\n\tif errors.As(err, &e) {\n\t\t// fix state store creds/access, then retry\n\t}\n\treturn fmt.Errorf(\"error writing additional objects: %w\", err)\n}","preventionTips":["Always set and verify KOPS_STATE_STORE / --state before create","Pre-validate manifests with kops create --dry-run","Confirm cloud credentials have write access to the state bucket","Keep addons YAML schema-current with your kops version"],"tags":["cli","state-store","addons"],"backgroundTag":"state-store-write-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"}