kubernetes/kops · error
failed to get volumes matching label selector %q: %w
Error message
failed to get volumes matching label selector %q: %w
What it means
GetVolumes wraps errors from hcloud VolumeClient.AllWithOpts when listing volumes filtered by the cluster label selector. It signals that the Hetzner Cloud API volume-list request failed, with the underlying hcloud error preserved.
Source
Thrown at upup/pkg/fi/cloudup/hetzner/cloud.go:240
return nil, fmt.Errorf("failed to get servers matching label selector %q: %w", labelSelector, err)
}
return matches, nil
}
func (c *hetznerCloudImplementation) GetVolumes(clusterName string) ([]*hcloud.Volume, error) {
client := c.VolumeClient()
labelSelector := TagKubernetesClusterName + "=" + clusterName
listOptions := hcloud.ListOpts{
PerPage: 50,
LabelSelector: labelSelector,
}
volumeListOptions := hcloud.VolumeListOpts{ListOpts: listOptions}
matches, err := client.AllWithOpts(context.TODO(), volumeListOptions)
if err != nil {
return nil, fmt.Errorf("failed to get volumes matching label selector %q: %w", labelSelector, err)
}
return matches, nil
}
func (c *hetznerCloudImplementation) DNS() (dnsprovider.Interface, error) {
// Hetzner LB has a stable internal IP and can use that instead of creating a record for api.internal.
return nil, nil
}
func (c *hetznerCloudImplementation) DeleteInstance(instance *cloudinstances.CloudInstance) error {
serverID, err := strconv.ParseInt(instance.ID, 10, 64)
if err != nil {
return fmt.Errorf("failed to convert server ID %q to int: %w", instance.ID, err)
}
err = deleteServer(c, serverID)
View on GitHub (pinned to 4c8573c808)
Solutions
- Validate HCLOUD_TOKEN is set, unexpired, and belongs to the cluster's project
- Retry after backoff if rate-limited (429)
- Verify outbound connectivity/proxy settings to api.hetzner.cloud
- Inspect the wrapped cause for the specific hcloud error code
Defensive patterns
Strategy: try-catch
Validate before calling
if os.Getenv("HCLOUD_TOKEN") == "" {
return fmt.Errorf("HCLOUD_TOKEN must be set before calling GetVolumes")
} Type guard
var hcloudErr *hcloud.Error
if errors.As(err, &hcloudErr) {
// branch on hcloudErr.Code
} Try / catch
vols, err := cloud.GetVolumes(clusterName)
if err != nil {
var hErr *hcloud.Error
if errors.As(err, &hErr) && hErr.Code == hcloud.ErrorCodeRateLimit {
time.Sleep(hErr.RateLimit.RetryAfter())
vols, err = cloud.GetVolumes(clusterName)
}
} Prevention
- Verify token validity/scoping before cluster operations
- Check proxy/firewall allows api.hetzner.cloud
- Unwrap errors to log precise hcloud error codes
- Add retry-on-429 logic around list operations
When it happens
Trigger: Calling GetVolumes with invalid credentials, no network access to api.hetzner.cloud, API rate limiting, or a Hetzner-side error on the /volumes endpoint.
Common situations: kOps cluster validation/deletion on Hetzner when the token expired, when running behind a corporate proxy blocking Hetzner API, or during Hetzner API incidents.
Related errors
- failed to list networks: %w
- failed to get firewalls matching label selector %q: %w
- failed to get load balancers matching label selector %q: %w
- failed to get servers matching label selector %q: %w
- failed to find network %q: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/f4766800920a02b7.
Report an issue: GitHub.