kubernetes/kops · error

cannot apply changes to Network: %v

Error message

cannot apply changes to Network: %v

What it means

Returned from Network.RenderGCE for an existing, non-legacy network when the residual diff is non-empty after the legacy check. The network task cannot apply in-place mutations, so any remaining change (after allowed no-op fields) is rejected.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/network.go:188

		default:
			return fmt.Errorf("unhandled mode %q", e.Mode)
		}

		op, err := t.Cloud.Compute().Networks().Insert(t.Cloud.Project(), network)
		if err != nil {
			return fmt.Errorf("error creating Network: %v", err)
		}
		if err := t.Cloud.WaitForOp(op); err != nil {
			return fmt.Errorf("error waiting for Network creation to complete: %w", err)
		}
	} else {
		if a.Mode == "legacy" {
			return fmt.Errorf("GCE networks in legacy mode are not supported.  Please convert to auto mode or specify a different network.")
		}
		empty := &Network{}
		if !reflect.DeepEqual(empty, changes) {
			return fmt.Errorf("cannot apply changes to Network: %v", changes)
		}
	}

	return nil
}

type terraformNetwork struct {
	Name                  *string `cty:"name"`
	IPv4Range             *string `cty:"ipv4_range"`
	Project               *string `cty:"project"`
	AutoCreateSubnetworks *bool   `cty:"auto_create_subnetworks"`
}

func (_ *Network) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Network) error {
	shared := fi.ValueOf(e.Shared)
	if shared {
		// Not terraform owned / managed
		return nil

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Review the printed diff to identify the drifted field(s)
  2. Align the cluster spec with the live network or adjust the network manually to match the spec
  3. Recreate the network only if it is safe to do so (shared networks usually are not)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/network.go:188 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/8c0e86711298fbbb. Report an issue: GitHub.