kubernetes/kops · error
error fetching subnet for patch: %w
Error message
error fetching subnet for patch: %w
What it means
Wrapped error from updateSecondaryRanges when the Subnetworks.Get re-fetch fails. The helper needs the current subnet state to build a patch for secondary ranges; failure means the subnet vanished between discovery and patch, or a permission/API error occurred.
Source
Thrown at upup/pkg/fi/cloudup/gcetasks/subnet.go:187
changes.StackType = nil
changes.Ipv6AccessType = nil
}
empty := &Subnet{}
if !reflect.DeepEqual(empty, changes) {
return fmt.Errorf("cannot apply changes to Subnet: %v", changes)
}
}
return nil
}
func updateSecondaryRanges(cloud gce.GCECloud, op string, e *Subnet) error {
// We need to refetch to patch it
subnet, err := cloud.Compute().Subnetworks().Get(cloud.Project(), cloud.Region(), *e.Name)
if err != nil {
return fmt.Errorf("error fetching subnet for patch: %w", err)
}
expectedRanges := e.SecondaryIpRanges
actualRanges := make(map[string]string)
for _, r := range subnet.SecondaryIpRanges {
actualRanges[r.RangeName] = r.IpCidrRange
}
// Cannot add and remove ranges in the same call
switch op {
case "add":
patch := false
for k, v := range expectedRanges {
if actualRanges[k] != v {
actualRanges[k] = v
subnet.SecondaryIpRanges = append(subnet.SecondaryIpRanges, &compute.SubnetworkSecondaryRange{
RangeName: k,View on GitHub (pinned to 4c8573c808)
Solutions
- Check the wrapped error for the API reason (404, 403, transient)
- Verify the subnet still exists in the region
- Re-run the apply; transient races usually resolve on retry
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/subnet.go:187 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/a5ebe4ad8e115f06.
Report an issue: GitHub.