kubernetes/kops · error
cannot update configuration file %s: does not exist
Error message
cannot update configuration file %s: does not exist
What it means
writeConfig() was invoked with vfs.WriteOptionOnlyIfExists (an update path) but a pre-flight ReadFile confirmed the configuration file does not exist in the state store. Updates are only allowed on existing objects, so this guards against silently creating a file via update.
Source
Thrown at pkg/client/simple/vfsclientset/commonvfs.go:149
return object, nil
}
func (c *VFSClientBase) writeConfig(ctx context.Context, cluster *kops.Cluster, configPath vfs.Path, o runtime.Object, writeOptions ...vfs.WriteOption) error {
data, err := c.serialize(o)
if err != nil {
return fmt.Errorf("error marshaling object: %v", err)
}
create := false
for _, writeOption := range writeOptions {
switch writeOption {
case vfs.WriteOptionCreate:
create = true
case vfs.WriteOptionOnlyIfExists:
_, err = configPath.ReadFile(ctx)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("cannot update configuration file %s: does not exist", configPath)
}
return fmt.Errorf("error checking if configuration file %s exists already: %v", configPath, err)
}
default:
return fmt.Errorf("unknown write option: %q", writeOption)
}
}
acl, err := acls.GetACL(ctx, configPath, cluster)
if err != nil {
return err
}
rs := bytes.NewReader(data)
if create {
err = configPath.CreateFile(ctx, rs, acl)
} else {
err = configPath.WriteFile(ctx, rs, acl)View on GitHub (pinned to 4c8573c808)
Solutions
- Verify the cluster/object name spelling and the KOPS_STATE_STORE bucket are correct.
- Check the file exists: `aws s3 ls $KOPS_STATE_STORE/<name>/cluster/spec` (or equivalent path).
- Create the object first with Create instead of Update if it genuinely doesn't exist.
- Restore from backup if the state store object was deleted unintentionally.
Example fix
// before kops update cluster --name typo.example.com // after kops get clusters # list actual cluster names kops update cluster --name prod.example.com
Defensive patterns
Strategy: validation
Validate before calling
existing, err := client.Find(ctx, name)
if err != nil { return err }
if existing == nil {
return fmt.Errorf("object %q does not exist in state store; use Create instead of Update", name)
} Try / catch
err := client.Update(ctx, obj)
if err != nil && strings.Contains(err.Error(), "does not exist") {
// create it first or correct the name/state store
} Prevention
- Always Get/Find the object before calling Update.
- Double-check cluster name spelling and KOPS_STATE_STORE.
- Avoid racing delete and update operations on the same cluster.
When it happens
Trigger: Update()/update() on a vfs clientset where the object file at basePath.Join(name) is missing — updating a cluster that was never created or was deleted.
Common situations: Running `kops update cluster` after `kops delete cluster` or with a mistyped cluster name; wrong KOPS_STATE_STORE so the object appears missing; racing deletion and update operations.
Related errors
- error reading full cluster spec for %q: %v
- error replacing cluster: %v
- reading kops-channels manifest %s: %w
- error parsing ConfigStore.Base %q: %v
- error reading state store: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/1f7d4c6cbfcc77c1.
Report an issue: GitHub.