{"record":{"id":"95acb6d1ba69055f","repo":"kubernetes/kops","slug":"error-listing-ports-v","errorCode":null,"errorMessage":"error listing ports: %v","messagePattern":"error listing ports: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/port.go","lineNumber":110,"sourceCode":"\t\treturn p, err\n\t} else if done {\n\t\treturn p, nil\n\t} else {\n\t\treturn p, wait.ErrWaitTimeout\n\t}\n}\n\nfunc (c *openstackCloud) ListPorts(opt ports.ListOptsBuilder) ([]ports.Port, error) {\n\treturn listPorts(c, opt)\n}\n\nfunc listPorts(c OpenstackCloud, opt ports.ListOptsBuilder) ([]ports.Port, error) {\n\tvar p []ports.Port\n\n\tdone, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {\n\t\tallPages, err := ports.List(c.NetworkingClient(), opt).AllPages(context.TODO())\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"error listing ports: %v\", err)\n\t\t}\n\n\t\tr, err := ports.ExtractPorts(allPages)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"error extracting ports from pages: %v\", err)\n\t\t}\n\t\tp = r\n\t\treturn true, nil\n\t})\n\tif err != nil {\n\t\treturn p, err\n\t} else if done {\n\t\treturn p, nil\n\t} else {\n\t\treturn p, wait.ErrWaitTimeout\n\t}\n}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/port.go#L92-L128","documentation":"listPorts (upup/pkg/fi/cloudup/openstack/port.go:110) pages through the Neutron port-list API inside a retry loop (readBackoff). If ports.List(...).AllPages fails — the HTTP request itself errors or pagination breaks — the error is wrapped with this message.","triggerScenarios":"ports.List(c.NetworkingClient(), opt).AllPages(context.TODO()) returns an error on every retry: unreachable/incorrect Neutron endpoint, 401/403 auth failure, malformed list filters (e.g. bad network_id or match query), or a dropped connection mid-pagination.","commonSituations":"Expired or misconfigured OpenStack credentials during cluster operations; wrong region/endpoint configured; Neutron API timeout on large projects with many ports; transient network partition between the client and the OpenStack API.","solutions":["Verify OS_* auth variables and that the token is valid (openstack port list works from CLI).","Check the Neutron endpoint/region configuration matches the target cloud.","Simplify or correct the ListOptsBuilder filters to ensure they are valid Neutron query parameters.","Re-run — readBackoff retries transient failures automatically."],"exampleFix":"// before\nallPages, err := ports.List(c.NetworkingClient(), opt).AllPages(context.TODO())\nif err != nil {\n    return false, fmt.Errorf(\"error listing ports: %v\", err)\n}\n// after — bound the call so a hung API cannot block forever\nctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)\ndefer cancel()\nallPages, err := ports.List(c.NetworkingClient(), opt).AllPages(ctx)\nif err != nil {\n    return false, fmt.Errorf(\"error listing ports: %v\", err)\n}","handlingStrategy":"retry","validationCode":"// Verify credentials and connectivity to Neutron before listing\n_, err := c.NetworkingClient().Get(\"/networks?limit=1\")\nif err != nil {\n    return fmt.Errorf(\"Neutron API not reachable with current credentials: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"ports, err := listPorts(c, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"error listing ports\") {\n        // listPorts already retried via readBackoff; log and surface the wrapped cause\n        return fmt.Errorf(\"port listing failed after retries: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate OS_* auth env/credentials periodically; refresh tokens before long operations.","Confirm the configured region/endpoint points at the correct Neutron service.","Keep list filters to valid Neutron query parameters.","Increase backoff windows for large projects where the API is slow."],"tags":["openstack","neutron","port-list","api"],"backgroundTag":"openstack-api-request-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"}