kubernetes/kops · error

fetching instance metadata: %w

Error message

fetching instance metadata: %w

What it means

getLinodeMetadataValue wraps the client.Do error from the token-authenticated GET /v1/instance request. It fires when the instance metadata endpoint is unreachable, the context expires, or the connection fails after a valid token was obtained.

Source

Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:110

	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)
	}

	value := parseLinodeMetadataValue(string(instanceBytes), key)
	if value == "" {
		return "", fmt.Errorf("instance %s from Akamai (Linode) metadata was empty", key)
	}
	return value, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check network connectivity to the Linode metadata service
  2. Ensure the context deadline allows both token and instance calls
  3. Retry on transient network failures with backoff
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:110 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/4432476ff5c322e6. Report an issue: GitHub.