kubernetes/kops · error

instance %s from Akamai (Linode) metadata was empty

Error message

instance %s from Akamai (Linode) metadata was empty

What it means

After successfully reading the metadata response body, getLinodeMetadataValue parses it with parseLinodeMetadataValue for the requested key. If the key is absent or its value is blank in the metadata document, the empty string is treated as an error. This means the metadata endpoint answered, but did not contain the requested field.

Source

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

	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 + ":"
	for _, line := range strings.Split(metadata, "\n") {
		line = strings.TrimSpace(line)
		if !strings.HasPrefix(line, prefix) {
			continue
		}
		return strings.TrimSpace(strings.TrimPrefix(line, prefix))
	}
	return ""
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the key name matches exactly what the Linode metadata service exposes
  2. Query the metadata endpoint manually (curl the URL) and inspect the raw document for the key
  3. Confirm the metadata service is fully initialized on the instance (retry shortly after boot)
  4. Handle the empty value at the call site with a sensible default or clearer error naming the expected key

Example fix

// before
value := parseLinodeMetadataValue(string(instanceBytes), key)
if value == "" {
	return "", fmt.Errorf("instance %s from Akamai (Linode) metadata was empty", key)
}
// after
value := parseLinodeMetadataValue(string(instanceBytes), key)
if value == "" {
	return "", fmt.Errorf("instance %s from Akamai (Linode) metadata was empty: check that key %q is exposed by the metadata service", key, key)
}
Defensive patterns

Strategy: validation

Validate before calling

value := parseLinodeMetadataValue(string(instanceBytes), key)
if value == "" { return fmt.Errorf("metadata key %q missing; available keys: %s", key, doc) }

Try / catch

v, err := getLinodeMetadataValue(ctx, key)
if err != nil {
	if strings.Contains(err.Error(), "was empty") { v = defaultValueFor(key) }
	return err
}

Prevention

When it happens

Trigger: parseLinodeMetadataValue(string(instanceBytes), key) returns "" because the metadata JSON/document has no entry for key, or the entry exists but is an empty string. Callers: GetMetadataValue and CreateToken requesting a key (e.g. region, instance id, token) that the endpoint did not return.

Common situations: Requesting a metadata key not present on this instance type or provider generation; typo'd key name; metadata service enabled but returns a partial/empty document during instance provisioning; unit test TestGetLinodeMetadataValueMissingKey deliberately hits this with a missing key.

Related errors


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