kubernetes/kops · error
could not initialize zones
Error message
could not initialize zones
What it means
findVPCInfo (backing FindVPCInfo) returns this when the zones slice passed in is empty — kOps cannot map subnets of the network to availability zones, so it refuses to build VPCInfo. It is a pre-condition failure, not an API error.
Source
Thrown at upup/pkg/fi/cloudup/openstack/cloud.go:577
func (c *openstackCloud) DNS() (dnsprovider.Interface, error) {
provider, err := dnsprovider.GetDnsProvider(designate.ProviderName, nil)
if err != nil {
return nil, fmt.Errorf("error building (Designate) DNS provider: %v", err)
}
return provider, nil
}
// FindVPCInfo list subnets in network
func (c *openstackCloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
return findVPCInfo(c, id, c.zones)
}
func findVPCInfo(c OpenstackCloud, id string, zones []string) (*fi.VPCInfo, error) {
vpcInfo := &fi.VPCInfo{}
// Find subnets in the network
{
if len(zones) == 0 {
return nil, fmt.Errorf("could not initialize zones")
}
klog.V(2).Infof("Calling ListSubnets for subnets in Network %q", id)
opt := subnets.ListOpts{
NetworkID: id,
}
subnets, err := c.ListSubnets(opt)
if err != nil {
return nil, fmt.Errorf("error listing subnets in network %q: %v", id, err)
}
for index, subnet := range subnets {
zone := zones[int(index)%len(zones)]
subnetInfo := &fi.SubnetInfo{
ID: subnet.ID,
CIDR: subnet.CIDR,
Zone: zone,
}
vpcInfo.Subnets = append(vpcInfo.Subnets, subnetInfo)View on GitHub (pinned to 4c8573c808)
Solutions
- Define zones in the cluster spec (kops set cluster.spec topology / zones) before update/create
- Verify the spec parses zones correctly (kops get cluster -oyaml | grep zones)
- If invoking findVPCInfo programmatically, pass a non-empty zones slice
Example fix
// before zones: [] // after zones: ["nova-1", "nova-2"]
Defensive patterns
Strategy: validation
Validate before calling
if len(zones) == 0 {
return nil, fmt.Errorf("zones must be non-empty before FindVPCInfo")
} Try / catch
// go
vpcInfo, err := cloud.FindVPCInfo(netID)
if err != nil && strings.Contains(err.Error(), "could not initialize zones") {
return fmt.Errorf("define zones in the cluster spec: %w", err)
} Prevention
- Always define topology zones in the cluster spec
- Validate the spec with kops before apply
- Check zones propagate into cloud discovery calls
When it happens
Trigger: FindVPCInfo called for a network id with zones == nil/empty, e.g. cluster spec defines no zones or zones were not propagated before the VPC lookup.
Common situations: Cluster spec missing topology/zones entries; zones list dropped during spec parsing; caller invoking FindVPCInfo directly in tests/tools without zone data.
Related errors
- failed to find cluster dns zone
- exactly one 'admin' SSH public key can be specified when run
- subnet %s not found in network %s
- cannot determine control-plane zones
- error finding openstack region: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/1142ee4597f2c6bf.
Report an issue: GitHub.