kubernetes/kops · error

converting zone %s to region: %w

Error message

converting zone %s to region: %w

What it means

Returned by GetServerIP when scw.Zone.Region() fails to derive a region from the zone string. Scaleway zones like `fr-par-1` map to region `fr-par`; an unparseable or malformed zone value causes this error. The zone and the underlying error are wrapped with %w.

Source

Thrown at upup/pkg/fi/cloudup/scaleway/cloud.go:502

	}
	return clusterSSHKeys, nil
}

func (s *scwCloudImplementation) GetClusterVolumes(clusterName string) ([]*instance.Volume, error) {
	volumes, err := s.instanceAPI.ListVolumes(&instance.ListVolumesRequest{
		Zone: s.zone,
		Tags: []string{TagClusterName + "=" + clusterName},
	}, scw.WithAllPages())
	if err != nil {
		return nil, fmt.Errorf("failed to list cluster volumes: %w", err)
	}
	return volumes.Volumes, nil
}

func (s *scwCloudImplementation) GetServerIP(serverID string, zone scw.Zone) (string, error) {
	region, err := zone.Region()
	if err != nil {
		return "", fmt.Errorf("converting zone %s to region: %w", zone, err)
	}

	ips, err := s.ipamAPI.ListIPs(&ipam.ListIPsRequest{
		Region:     region,
		IsIPv6:     new(false),
		ResourceID: &serverID,
		Zonal:      new(zone.String()),
	}, scw.WithAllPages())
	if err != nil {
		return "", fmt.Errorf("listing IPs for server %s: %w", serverID, err)
	}

	if len(ips.IPs) < 1 {
		return "", fmt.Errorf("could not find IP for server %s", serverID)
	}
	if len(ips.IPs) > 1 {
		klog.V(10).Infof("Found more than 1 IP for server %s, using %s", serverID, ips.IPs[0].Address.IP.String())
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Print/verify the zone value reaching GetServerIP; it must be a full zone like `fr-par-1`, not a region.
  2. Upgrade kops / the scaleway-go SDK to a version that knows the zone's region (new zones require newer SDKs).
  3. Fix the cloud group or cluster spec that supplied the malformed zone.
  4. Guard the call site: validate the zone format before calling GetServerIP.

Example fix

// before
zone := group.Zone // possibly "fr-par" (a region)
ip, err := cloud.GetServerIP(serverID, zone)
// after
zone := group.Zone
if strings.Count(string(zone), "-") < 2 {
  return fmt.Errorf("invalid zone %q, expected format like fr-par-1", zone)
}
ip, err := cloud.GetServerIP(serverID, zone)
Defensive patterns

Strategy: validation

Validate before calling

func isZone(s string) bool {
  return regexp.MustCompile(`^[a-z]{2}-[a-z]+-[0-9]+$`).MatchString(s)
}
// call only if isZone(string(zone))

Type guard

func validZone(z scw.Zone) bool {
  _, err := z.Region()
  return err == nil
}

Prevention

When it happens

Trigger: zone value is empty, malformed (e.g. missing the numeric suffix like `fr-par-`), a region name passed by mistake instead of a zone (e.g. `fr-par`), or a zone string from an unknown/new region the SDK version doesn't recognize.

Common situations: Cluster config or cloud group built with a region instead of a zone; server discovered in a zone newer than the vendored Scaleway SDK version; empty zone propagated from an earlier failed lookup.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5d1b9806a07ae630. Report an issue: GitHub.