kubernetes/kops · error

subnet ID not set

Error message

subnet ID not set

What it means

findExistingRouteTableForSubnet refuses to look up a route table when the task's associated Subnet task has no ID, meaning the subnet has not yet been resolved to an AWS resource (not created or not found). kOps throws this to fail fast instead of making a DescribeRouteTables call with an empty subnet-id filter that would return bogus results.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/routetableassociation.go:126

	}
	if a != nil {
		if changes.RouteTable != nil {
			return fi.CannotChangeField("RouteTable")
		}
		if changes.Subnet != nil {
			return fi.CannotChangeField("Subnet")
		}
	}
	return nil
}

func findExistingRouteTableForSubnet(cloud awsup.AWSCloud, subnet *Subnet) (*ec2types.RouteTable, error) {
	ctx := context.TODO()
	if subnet == nil {
		return nil, fmt.Errorf("subnet not set")
	}
	if subnet.ID == nil {
		return nil, fmt.Errorf("subnet ID not set")
	}

	subnetID := fi.ValueOf(subnet.ID)

	request := &ec2.DescribeRouteTablesInput{
		Filters: []ec2types.Filter{awsup.NewEC2Filter("association.subnet-id", subnetID)},
	}
	response, err := cloud.EC2().DescribeRouteTables(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("error listing RouteTables for subnet %q: %v", subnetID, err)
	}
	if response == nil || len(response.RouteTables) == 0 {
		return nil, nil
	}

	if len(response.RouteTables) != 1 {
		return nil, fmt.Errorf("found multiple RouteTables attached to subnet")
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the subnet actually exists in AWS and its ID is in the cluster spec (spec.subnets[*].id)
  2. Run kops update with --v=2 to check whether the Subnet task found its ID before the association task
  3. Re-run the update so the Subnet task completes before RouteTableAssociation; fix upstream failures in the Subnet find/create
  4. If using shared subnets, ensure subnet IDs are set explicitly in the cluster spec
Defensive patterns

Strategy: validation

Validate before calling

// before kops update
aws ec2 describe-subnets --subnet-ids <subnet-id>  # must exist and appear in cluster spec
kops get cluster -o yaml | grep -A3 'subnets:'

Prevention

When it happens

Trigger: RenderAWS of a RouteTableAssociation whose e.Subnet is non-nil but e.Subnet.ID is nil — i.e., the Subnet task did not run/find first, subnet lookup failed silently upstream, or task ordering left the subnet unresolved.

Common situations: Reconciling an existing cluster where the referenced subnet was deleted out-of-band; misconfigured cluster spec referencing subnets that kOps never created; running kops update against a cluster with stale state store where Subnet task discovery failed.

Related errors


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