kubernetes/kops · error
cannot apply changes to Instance: %v
Error message
cannot apply changes to Instance: %v
What it means
Returned from Instance.RenderGCE after metadata updates are applied when the remaining diff is still non-zero. Instances cannot be mutated in place for most fields (machine type, zone, disks, network config), so any leftover change is rejected.
Source
Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:353
klog.V(2).Infof("Updating instance metadata on %q", i.Name)
i.Metadata.Fingerprint = a.metadataFingerprint
op, err := cloud.Compute().Instances().SetMetadata(project, zone, i.Name, i.Metadata)
if err != nil {
return fmt.Errorf("error setting metadata on instance: %v", err)
}
if err := cloud.WaitForOp(op); err != nil {
return fmt.Errorf("error setting metadata on instance: %v", err)
}
changes.Metadata = nil
}
if !changes.isZero() {
klog.Errorf("Cannot apply changes to Instance: %v", changes)
return fmt.Errorf("cannot apply changes to Instance: %v", changes)
}
}
return nil
}
func BuildMachineTypeURL(project, zone, name string) string {
return fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/zones/%s/machineTypes/%s", project, zone, name)
}
func BuildImageURL(defaultProject, nameSpec string) string {
tokens := strings.Split(nameSpec, "/")
var project, name string
if len(tokens) == 2 {
project = tokens[0]
name = tokens[1]
} else if len(tokens) == 1 {
project = defaultProjectView on GitHub (pinned to 4c8573c808)
Solutions
- Examine the printed changes to see which fields drifted (klog.Error logs the same diff)
- Align the cluster spec with the actual instance, or roll the instance group so instances are recreated with the new config
- For immutable-field changes, perform a rolling update instead of an in-place apply
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:353 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/65ac8f27b66f807d.
Report an issue: GitHub.