kubernetes/kops · error

could not list ports %v

Error message

could not list ports %v

What it means

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.

Source

Thrown at upup/pkg/fi/cloudup/openstack/cloud.go:627

	if !ok || value != instanceGroupName {
		return false
	}
	cName, clusterok := instance.Metadata["k8s"]
	if !clusterok || cName != clusterName {
		return false
	}
	return true
}

func deletePorts(c OpenstackCloud, instanceGroupName string, clusterName string) error {
	tags := []string{
		fmt.Sprintf("%s=%s", TagClusterName, clusterName),
		fmt.Sprintf("%s=%s", TagKopsInstanceGroup, instanceGroupName),
	}

	ports, err := c.ListPorts(ports.ListOpts{Tags: strings.Join(tags, ",")})
	if err != nil {
		return fmt.Errorf("could not list ports %v", err)
	}

	for _, port := range ports {
		klog.V(2).Infof("Delete port '%s' (%s)", port.Name, port.ID)
		err := c.DeletePort(port.ID)

		if err != nil {
			return fmt.Errorf("could not delete port %q: %v", port.ID, err)
		}
	}

	return nil
}

func deleteGroup(c OpenstackCloud, g *cloudinstances.CloudInstanceGroup) error {
	cluster := g.Raw.(*kops.Cluster)
	allInstances, err := c.ListInstances(servers.ListOpts{
		Name: fmt.Sprintf("^%s", g.InstanceGroup.Name),

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Confirm Neutron supports port tag filtering (2.0+ with tag filters); upgrade Neutron or kops if not
  2. Re-authenticate and retry the delete operation
  3. Check Neutron API health/connectivity and inspect the wrapped %v error
  4. Manually verify/delete the tagged ports via 'openstack port list --tags <cluster-tag>' as a workaround

Example fix

// before: retry against failing API without checks
err := c.ListPorts(ports.ListOpts{Tags: tags})
// after: check neutron tag support / re-auth first, then retry, e.g. wrap with backoff
err := retry.OnError(backoff, func(e error) bool { return isTransient(e) }, func() error {
    _, err := c.ListPorts(ports.ListOpts{Tags: tags}); return err
})
Defensive patterns

Strategy: retry

Validate before calling

// ensure token validity before the delete flow
_, err := neutron.GetAuthResult(ctx)
if err != nil { reauth(ctx); }

Try / catch

// go
err := deletePortsForInstanceGroup(cloud, clusterName, igName)
if err != nil && strings.Contains(err.Error(), "could not list ports") {
    // re-authenticate and retry with backoff before surfacing to user
}

Prevention

When it happens

Trigger: 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.

Common situations: Older Neutron without port tag filtering support; token expired mid-deletion; transient Neutron outage during 'kops delete instancegroup' or cluster teardown.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/bc6fac3fe4ce456c. Report an issue: GitHub.