{"record":{"id":"bc6fac3fe4ce456c","repo":"kubernetes/kops","slug":"could-not-list-ports-v","errorCode":null,"errorMessage":"could not list ports %v","messagePattern":"could not list ports (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/cloud.go","lineNumber":627,"sourceCode":"\tif !ok || value != instanceGroupName {\n\t\treturn false\n\t}\n\tcName, clusterok := instance.Metadata[\"k8s\"]\n\tif !clusterok || cName != clusterName {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc deletePorts(c OpenstackCloud, instanceGroupName string, clusterName string) error {\n\ttags := []string{\n\t\tfmt.Sprintf(\"%s=%s\", TagClusterName, clusterName),\n\t\tfmt.Sprintf(\"%s=%s\", TagKopsInstanceGroup, instanceGroupName),\n\t}\n\n\tports, err := c.ListPorts(ports.ListOpts{Tags: strings.Join(tags, \",\")})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not list ports %v\", err)\n\t}\n\n\tfor _, port := range ports {\n\t\tklog.V(2).Infof(\"Delete port '%s' (%s)\", port.Name, port.ID)\n\t\terr := c.DeletePort(port.ID)\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not delete port %q: %v\", port.ID, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc deleteGroup(c OpenstackCloud, g *cloudinstances.CloudInstanceGroup) error {\n\tcluster := g.Raw.(*kops.Cluster)\n\tallInstances, err := c.ListInstances(servers.ListOpts{\n\t\tName: fmt.Sprintf(\"^%s\", g.InstanceGroup.Name),","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/cloud.go#L609-L645","documentation":"Returned while deleting leftover instance-group ports: c.ListPorts with a tag filter (TagClusterName + TagKopsInstanceGroup) failed. Without the port list, kOps cannot proceed to delete orphaned ports for the cluster/instance group.","triggerScenarios":"ListPorts(ports.ListOpts{Tags: \"kops.k8s.io/cluster=...,kops.k8s.io/instance-group=...\"}) errors — Neutron API failure, tag-filter unsupported/rejected by the Neutron version, auth expiry, or endpoint unreachable.","commonSituations":"Older Neutron without port tag filtering support; token expired mid-deletion; transient Neutron outage during 'kops delete instancegroup' or cluster teardown.","solutions":["Confirm Neutron supports port tag filtering (2.0+ with tag filters); upgrade Neutron or kops if not","Re-authenticate and retry the delete operation","Check Neutron API health/connectivity and inspect the wrapped %v error","Manually verify/delete the tagged ports via 'openstack port list --tags <cluster-tag>' as a workaround"],"exampleFix":"// before: retry against failing API without checks\nerr := c.ListPorts(ports.ListOpts{Tags: tags})\n// after: check neutron tag support / re-auth first, then retry, e.g. wrap with backoff\nerr := retry.OnError(backoff, func(e error) bool { return isTransient(e) }, func() error {\n    _, err := c.ListPorts(ports.ListOpts{Tags: tags}); return err\n})","handlingStrategy":"retry","validationCode":"// ensure token validity before the delete flow\n_, err := neutron.GetAuthResult(ctx)\nif err != nil { reauth(ctx); }","typeGuard":null,"tryCatchPattern":"// go\nerr := deletePortsForInstanceGroup(cloud, clusterName, igName)\nif err != nil && strings.Contains(err.Error(), \"could not list ports\") {\n    // re-authenticate and retry with backoff before surfacing to user\n}","preventionTips":["Run delete flows with fresh tokens","Verify Neutron supports tag-based port filtering","Manually reconcile tagged ports if API filtering fails: 'openstack port list --tags'"],"tags":["openstack","neutron","ports","api"],"backgroundTag":"openstack-api-list-failed","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"}