kubernetes/kops · error
error retrieving subnet: %v
Error message
error retrieving subnet: %v
What it means
getSubnet fetches a single Neutron subnet by ID inside a RetryWithBackoff loop. If subnets.Get(...).Extract() fails, the error is wrapped as "error retrieving subnet: %v". Note the OpenStack SDK returns 404 for a missing subnet, which usually surfaces here as a wrapped gophercloud ErrResourceNotFound.
Source
Thrown at upup/pkg/fi/cloudup/openstack/subnet.go:67
if err != nil {
return s, err
} else if done {
return s, nil
} else {
return s, wait.ErrWaitTimeout
}
}
func (c *openstackCloud) GetSubnet(subnetID string) (*subnets.Subnet, error) {
return getSubnet(c, subnetID)
}
func getSubnet(c OpenstackCloud, subnetID string) (*subnets.Subnet, error) {
var subnet *subnets.Subnet
done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
sub, err := subnets.Get(context.TODO(), c.NetworkingClient(), subnetID).Extract()
if err != nil {
return false, fmt.Errorf("error retrieving subnet: %v", err)
}
subnet = sub
return true, nil
})
if err != nil {
return nil, err
} else if done {
return subnet, nil
} else {
return nil, wait.ErrWaitTimeout
}
}
func (c *openstackCloud) CreateSubnet(opt subnets.CreateOptsBuilder) (*subnets.Subnet, error) {
return createSubnet(c, opt)
}
func createSubnet(c OpenstackCloud, opt subnets.CreateOptsBuilder) (*subnets.Subnet, error) {View on GitHub (pinned to 4c8573c808)
Solutions
- Verify the subnet UUID exists: `openstack subnet show <subnetID>` in the same project/region
- Correct the subnet ID in the kops cluster spec if it was deleted or mistyped
- Check RBAC policy if the error is 403
- Re-authenticate if the wrapped error is 401
Defensive patterns
Strategy: validation
Validate before calling
func subnetExists(subnetID string) error {
if _, err := exec.Command("openstack", "subnet", "show", subnetID).Output(); err != nil {
return fmt.Errorf("subnet %s not found in project/region", subnetID)
}
return nil
} Type guard
func isNotFoundErr(err error) bool {
var nf gophercloud.ErrResourceNotFound
return errors.As(err, &nf)
} Try / catch
sub, err := getSubnet(cloud, id)
if err != nil {
if isNotFoundErr(err) {
return nil, fmt.Errorf("subnet %q does not exist; fix cluster spec", id)
}
return nil, err
} Prevention
- Verify subnet UUIDs with openstack CLI before putting them in the spec
- Keep subnet IDs in a single source of truth per region
- Watch for out-of-band subnet deletion via OpenStack audit logs
- Ensure kops runs in the same project/region as the subnet
When it happens
Trigger: The subnet ID passed does not exist (deleted out-of-band, wrong region/project), the token lacks read access to the subnet, or Neutron is unreachable.
Common situations: Cluster config referencing a subnet deleted manually, cross-project/cross-region subnet reference, expired credentials, or a typo in the subnet UUID in the cluster spec.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- error retrieving subnet with id %s: %v
- error listing subnets in network %q: %v
- error retrieving network with id %s: %v
- error listing subnets: %v
- error extracting subnets from pages: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/1c4a5d10aa6f880e.
Report an issue: GitHub.