kubernetes/kops · error
building instance metadata request: %w
Error message
building instance metadata request: %w
What it means
getLinodeMetadataValue wraps the http.NewRequestWithContext error when constructing the GET /v1/instance request that carries the metadata token. Like the token-request build error, it only fires on an invalid URL/method, i.e. a malformed metadataBaseURL.
Source
Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:104
defer tokenResp.Body.Close()
if tokenResp.StatusCode != http.StatusOK {
return "", fmt.Errorf("fetching metadata token: unexpected status code %d", tokenResp.StatusCode)
}
tokenBytes, err := io.ReadAll(tokenResp.Body)
if err != nil {
return "", fmt.Errorf("reading metadata token response: %w", err)
}
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)
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Validate metadataBaseURL is a well-formed absolute URL
- Fix the configuration/code defect rather than retrying, since the error is deterministic
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:104 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/b83200697135c3a5.
Report an issue: GitHub.