kubernetes/kops · error

failed to deregister instance from load balancers: %v

Error message

failed to deregister instance from load balancers: %v

What it means

This error aggregates failures from deregisterInstance, which concurrently drains the instance from all Octavia/Neutron-LB load balancers it is attached to using an errgroup. If any single LB drain fails, eg.Wait() returns and the whole deregistration is reported as failed with this wrapper message.

Source

Thrown at upup/pkg/fi/cloudup/openstack/instance.go:252

		kopsName = fmt.Sprintf("%s-%s", clusterName, ig)
	}

	lbs, err := c.ListLBs(loadbalancers.ListOpts{})
	if err != nil {
		return err
	}
	ctx := context.Background()
	eg, _ := errgroup.WithContext(ctx)
	for i := range lbs {
		func(lb loadbalancers.LoadBalancer) {
			eg.Go(func() error {
				return drainSingleLB(c, lb, instanceName, kopsName)
			})
		}(lbs[i])
	}

	if err := eg.Wait(); err != nil {
		return fmt.Errorf("failed to deregister instance from load balancers: %v", err)
	}

	return nil
}

// drainSingleLB will drain single loadbalancer that is attached to instance
func drainSingleLB(c OpenstackCloud, lb loadbalancers.LoadBalancer, instanceName string, kopsName string) error {
	oldStats, err := c.GetLBStats(lb.ID)
	if err != nil {
		return err
	}

	draining := false
	pools, err := c.ListPools(v2pools.ListOpts{
		LoadbalancerID: lb.ID,
	})
	if err != nil {
		return err

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the aggregated %v error to find which LB(s) failed and their underlying cause
  2. Verify the load balancers still exist with `openstack loadbalancer list`; remove stale LB references from the cluster config if LBs were deleted manually
  3. Increase the LB drain timeout / reduce concurrency if Octavia is rate-limiting member removals
  4. Manually remove the member from the LB pool (`openstack loadbalancer member delete`) and retry the kops operation
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check the instance's LB members before deregistering
for _, lb := range lbs {
    members, err := cloud.ListLBMembers(lb)
    if err != nil { return fmt.Errorf("cannot inspect LB %s: %w", lb.ID, err) }
    _ = members
}

Try / catch

err := DeregisterInstance(cloud, instance)
if err != nil {
    var agg []string
    if strings.Contains(err.Error(), "failed to deregister instance from load balancers") {
        // log and continue delete; LB membership is eventually consistent
        klog.Warningf("deregistration failed, continuing: %v", err)
    }
    _ = agg
}

Prevention

When it happens

Trigger: drainSingleLB fails for one or more load balancers: LB not found, member removal API call errors, the instance never becomes fully drained within the drain timeout, or the load balancer API is unavailable.

Common situations: Deleting a instance-group member whose load balancer was already deleted out-of-band; Octavia service down or overloaded; member stuck in draining state exceeding the drain interval configured for the cluster.

Related errors


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