{"record":{"id":"cf75099452637bdc","repo":"kubernetes/kops","slug":"error-tagging-instance-q-v","errorCode":null,"errorMessage":"error tagging instance %q: %v","messagePattern":"error tagging instance %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":684,"sourceCode":"\tif i.Status == cloudinstances.CloudInstanceStatusDetached {\n\t\treturn nil\n\t}\n\tif c.spotinst != nil {\n\t\treturn spotinst.DetachInstance(c.spotinst, i)\n\t}\n\n\treturn detachInstance(ctx, c, i)\n}\n\nfunc detachInstance(ctx context.Context, c AWSCloud, i *cloudinstances.CloudInstance) error {\n\tid := i.ID\n\tif id == \"\" {\n\t\treturn fmt.Errorf(\"id was not set on CloudInstance: %v\", i)\n\t}\n\n\tasg := i.CloudInstanceGroup.Raw.(*autoscalingtypes.AutoScalingGroup)\n\tif err := c.CreateTags(id, map[string]string{tagNameDetachedInstance: *asg.AutoScalingGroupName}); err != nil {\n\t\treturn fmt.Errorf(\"error tagging instance %q: %v\", id, err)\n\t}\n\n\t// TODO this also deregisters the instance from any ELB attached to the ASG. Do we care?\n\n\tinput := &autoscaling.DetachInstancesInput{\n\t\tAutoScalingGroupName:           aws.String(i.CloudInstanceGroup.HumanName),\n\t\tInstanceIds:                    []string{id},\n\t\tShouldDecrementDesiredCapacity: aws.Bool(false),\n\t}\n\n\tif _, err := c.Autoscaling().DetachInstances(ctx, input); err != nil {\n\t\treturn fmt.Errorf(\"error detaching instance %q: %v\", id, err)\n\t}\n\n\tklog.V(8).Infof(\"detached aws ec2 instance %q\", id)\n\n\treturn nil\n}","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L666-L702","documentation":"During rolling update, kOps first tags the instance with the detached-instance tag (its ASG name) before detaching it; the CreateTags EC2 call failed, so the detach flow aborts with the wrapped AWS error.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:684 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check ec2:CreateTags permissions for the credentials in use","Retry the rolling update for transient API errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}