{"record":{"id":"7c69b51a091c4b7d","repo":"kubernetes/kops","slug":"error-reading-target-lifecycle-state-from-instance","errorCode":null,"errorMessage":"error reading target-lifecycle-state from instance metadata: %v","messagePattern":"error reading target-lifecycle-state from instance metadata: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/command.go","lineNumber":881,"sourceCode":"\t// Check if WarmPool is enabled first, to avoid additional API calls\n\tif len(c.NodeupConfig.WarmPoolImages) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\t// Only worker nodes and apiservers can actually autoscale.\n\t// We are not adding describe permissions to the other roles\n\trole := c.BootConfig.InstanceGroupRole\n\tif !role.HasNode() && !role.HasAPIServer() {\n\t\treturn \"\", nil\n\t}\n\n\ttargetLifecycleState, err := vfs.Context.ReadFile(\"metadata://aws/meta-data/autoscaling/target-lifecycle-state\")\n\tif err != nil {\n\t\tvar awsErr *awshttp.ResponseError\n\t\tif errors.As(err, &awsErr) && awsErr.HTTPStatusCode() == http.StatusNotFound {\n\t\t\treturn \"\", nil\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"error reading target-lifecycle-state from instance metadata: %v\", err)\n\t}\n\n\tif strings.HasPrefix(string(targetLifecycleState), \"Warmed:\") {\n\t\tklog.Info(\"instance is entering warm pool\")\n\t\treturn model.ConfigurationModeWarming, nil\n\t} else {\n\t\tklog.Info(\"instance is entering the ASG\")\n\t\treturn \"\", nil\n\t}\n}\n","sourceCodeStart":863,"sourceCodeEnd":892,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/command.go#L863-L892","documentation":"getAWSConfigurationMode reads the EC2 instance-metadata key target-lifecycle-state to detect warm-pool nodes. If the metadata read fails with any error other than HTTP 404, nodeup returns this wrapped error and aborts. It is thrown because instance metadata was unreachable or returned an unexpected status.","triggerScenarios":"vfs read of metadata://aws/meta-data/autoscaling/target-lifecycle-state fails with a non-404 error — metadata service unreachable, HTTP 403 (IMDSv2 token issue), timeout, or 500.","commonSituations":"Instance metadata options set to require tokens but hop limit blocks nodeup; metadata service disabled on the ASG; networking issue in a launching instance; non-AWS environment where this metadata path does not exist.","solutions":["Verify IMDS is enabled and reachable: `curl -H \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data/autoscaling/target-lifecycle-state`","Check instance metadata options on the ASG (http-tokens, http-hop-limit=2, http-endpoint=enabled)","Confirm the instance is launched from an ASG with warm pool configured; 404 is tolerated, other statuses are fatal","Retry nodeup — transient metadata unavailability during instance launch resolves shortly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"token, _ := imdsToken(ctx)\nresp, err := client.Get(\"http://169.254.169.254/latest/meta-data/autoscaling/target-lifecycle-state\")\n// treat 404 as \"no warm pool\", any other failure as environment problem to fix first","typeGuard":null,"tryCatchPattern":"if err := runNodeup(ctx); err != nil {\n  if strings.Contains(err.Error(), \"target-lifecycle-state\") {\n    // wait briefly and retry: IMDS is often transiently unavailable at launch\n    time.Sleep(5 * time.Second)\n    return runNodeup(ctx)\n  }\n  return err\n}","preventionTips":["Keep IMDS enabled with http-endpoint=enabled and hop-limit >= 2 on the ASG","Use IMDSv2-compatible metadata clients in nodeup environments","Configure ASG launch templates so warm-pool nodes still allow metadata access","Distinguish expected 404 (no warm pool) from real failures when customizing"],"tags":["aws","metadata","nodeup"],"backgroundTag":"metadata-service-unreachable","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}