kubernetes/kops · error

waiting for nat gateway deletion completion

Error message

waiting for nat gateway deletion completion: %w

What it means

PollUntilDone failed while waiting for the NAT gateway deletion LRO; the delete was accepted but the operation failed (commonly because subnets still reference the NAT gateway).

Solutions

  1. Detach subnets using the NAT gateway and retry deletion
  2. Inspect the wrapped error for the failure reason
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/azure/natgateway.go:81 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at upup/pkg/fi/cloudup/azure/natgateway.go:81

		if err != nil {
			var respErr *azcore.ResponseError
			if errors.As(err, &respErr) && respErr.ErrorCode == "ResourceGroupNotFound" {
				return nil, nil
			}
			return nil, fmt.Errorf("listing nat gateways: %w", err)
		}
		l = append(l, resp.Value...)
	}
	return l, nil
}

func (c *NatGatewaysClientImpl) Delete(ctx context.Context, resourceGroupName, natGatewayName string) error {
	future, err := c.c.BeginDelete(ctx, resourceGroupName, natGatewayName, nil)
	if err != nil {
		return fmt.Errorf("deleting nat gateway: %w", err)
	}
	if _, err := future.PollUntilDone(ctx, nil); err != nil {
		return fmt.Errorf("waiting for nat gateway deletion completion: %w", err)
	}
	return nil
}

func newNatGatewaysClientImpl(subscriptionID string, cred *azidentity.DefaultAzureCredential) (*NatGatewaysClientImpl, error) {
	c, err := network.NewNatGatewaysClient(subscriptionID, cred, nil)
	if err != nil {
		return nil, fmt.Errorf("creating nat gateways client: %w", err)
	}
	return &NatGatewaysClientImpl{
		c: c,
	}, nil
}

View on GitHub (pinned to 4c8573c808)