kubernetes/kops · error
fetching instance metadata: unexpected status code %d
Error message
fetching instance metadata: unexpected status code %d
What it means
getLinodeMetadataValue rejects the instance metadata response because GET /v1/instance returned a non-200 status. It fires when the metadata token was rejected/expired or the instance metadata service is disabled, so the requested key cannot be read.
Source
Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:115
token := strings.TrimSpace(string(tokenBytes))
if token == "" {
return "", fmt.Errorf("metadata token was empty")
}
instanceReq, err := http.NewRequestWithContext(ctx, http.MethodGet, metadataBaseURL+"/v1/instance", nil)
if err != nil {
return "", fmt.Errorf("building instance metadata request: %w", err)
}
instanceReq.Header.Set("Metadata-Token", token)
instanceResp, err := client.Do(instanceReq)
if err != nil {
return "", fmt.Errorf("fetching instance metadata: %w", err)
}
defer instanceResp.Body.Close()
if instanceResp.StatusCode != http.StatusOK {
return "", fmt.Errorf("fetching instance metadata: unexpected status code %d", instanceResp.StatusCode)
}
instanceBytes, err := io.ReadAll(instanceResp.Body)
if err != nil {
return "", fmt.Errorf("reading instance metadata response: %w", err)
}
value := parseLinodeMetadataValue(string(instanceBytes), key)
if value == "" {
return "", fmt.Errorf("instance %s from Akamai (Linode) metadata was empty", key)
}
return value, nil
}
// parseLinodeMetadataValue parses the Akamai (Linode) metadata response for the given key
// and returns the value as a string.
func parseLinodeMetadataValue(metadata string, key string) string {
prefix := key + ":"View on GitHub (pinned to 4c8573c808)
Solutions
- On 401/403, re-mint the metadata token and retry; the token may have expired
- On 404, verify the metadata service is enabled for the instance
- Retry with backoff on 429/5xx
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:115 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/7b8a2335d91f6df3.
Report an issue: GitHub.