{"record":{"id":"6fedfba7f9b1356c","repo":"kubernetes/kops","slug":"found-d-instances-with-name-s","errorCode":null,"errorMessage":"found %d instances with name: %s","messagePattern":"found (.+?) instances with name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstacktasks/servergroup.go","lineNumber":200,"sourceCode":"\t\t\t\t\t\tval, ok = server.Metadata[openstack.TagKopsName]\n\t\t\t\t\t\tif ok {\n\t\t\t\t\t\t\tmetadataName = val\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// name or metadata tag should match to instance name\n\t\t\t\t\t\t// this is needed for backwards compatibility\n\t\t\t\t\t\tif server.Name == instanceName || metadataName == instanceName {\n\t\t\t\t\t\t\tinstances = append(instances, server)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif len(instances) == 1 {\n\t\t\t\t\t\tklog.V(2).Infof(\"Openstack task ServerGroup scaling down instance %s\", instanceName)\n\t\t\t\t\t\terr := t.Cloud.DeleteInstanceWithID(instances[0].ID)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"Could not delete instance %s: %v\", instanceName, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn fmt.Errorf(\"found %d instances with name: %s\", len(instances), instanceName)\n\t\t\t\t\t}\n\t\t\t\t\tcurrentLastIndex -= 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tklog.V(2).Infof(\"Openstack task ServerGroup::RenderOpenstack did nothing\")\n\treturn nil\n}\n","sourceCodeStart":182,"sourceCodeEnd":212,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstacktasks/servergroup.go#L182-L212","documentation":"RenderOpenstack returns this when the ServerGroup scale-down found an instance matching the instance-group name prefix but the count is not exactly 1 — the task only safely deletes when a single candidate exists. It is a deliberate safety check against deleting the wrong instance (e.g. 0 means the target was already gone, >1 means ambiguous name matches).","triggerScenarios":"Scale-down loop (changes.IGMap) where the regex Name filter '^<igName>' matched 0 or 2+ servers with metadata k8s == clusterName for the target instance name. Zero matches when the instance was already deleted externally; multiple matches when instance names share a prefix (e.g. nodes.cluster-a and nodes.cluster-a-b) or duplicates exist from a previous failed scale-down.","commonSituations":"Cluster name is a prefix of another cluster's instance-group names, so the '^name' regex over-matches; leftover duplicate instances from an interrupted roll; manual instance creation with a colliding name; the instance was already deleted by an autoscaler (0 matches).","solutions":["List servers with 'openstack server list' and manually delete the surplus/obsolete instance so exactly one remains, then re-run kops update.","Ensure instance-group/cluster names are not prefixes of one another, or increase distinctiveness of the IG name.","Check metadata k8s=<clusterName> on the instances — mislabeled/duplicated instances outside the cluster should be removed manually.","If 0 instances found (already deleted), simply re-run 'kops update cluster --yes' to converge state."],"exampleFix":"// avoid prefix collisions by naming IGs distinctly\n// before\nigName = \"nodes\"        // matches nodes-a, nodes-b\n// after\nigName = \"nodes-prod-eu\" // unique prefix","handlingStrategy":"validation","validationCode":"# Ensure exactly one match before scale-down, mirroring the task's invariant\ncount=$(openstack server list --name \"^${igName}\" -f value | wc -l)\n[ \"$count\" -eq 1 ] || echo \"expected 1 instance named ${igName}, found $count — reconcile manually\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose cluster/IG names that are not prefixes of each other.","Delete leftover duplicate instances from failed rolls before re-applying.","Keep instance metadata k8s=<clusterName> intact so matching stays exact.","Audit with 'openstack server list' before planned scale-downs."],"tags":["openstack","nova","scale-down","naming-collision"],"backgroundTag":"ambiguous-instance-name-match","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"}