kubernetes/kops · error
subnet not set
Error message
subnet not set
What it means
findExistingRouteTableForSubnet guards its input: if the *Subnet pointer is nil, there is no subnet to find a route table for, so it returns this error before making any AWS call. It is a programming/state invariant check, not an AWS failure.
Source
Thrown at upup/pkg/fi/cloudup/awstasks/routetableassociation.go:123
if e.Subnet == nil {
return fi.RequiredField("Subnet")
}
}
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
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Ensure the RouteTableAssociation's Subnet reference in the cluster spec points to a defined subnet
- Run `kops get clusters --full` / inspect the manifest to verify subnet entries
- Re-create the task state by re-running `kops update cluster` from a clean spec
- If it occurs with a valid spec, file a kOps bug — a nil subnet reaching RenderAWS is an internal invariant failure
Example fix
// before (spec): association without subnet
routeTableAssociation: {}
// after:
routeTableAssociation:
subnet: us-test-1a
routeTable: main Defensive patterns
Strategy: validation
Validate before calling
// validate spec before update
for _, a := range spec.RouteTableAssociations {
if a.Subnet == nil || a.Subnet.Name == "" { return fmt.Errorf("association %s missing subnet", a.Name) }
} Type guard
func subnetIsSet(s *awstasks.Subnet) bool { return s != nil && s.ID != nil } Try / catch
rt, err := findExistingRouteTableForSubnet(cloud, subnet)
if err != nil && err.Error() == "subnet not set" {
return fmt.Errorf("task misconfigured: association has no Subnet reference")
} Prevention
- Always reference an existing subnet in route table associations
- Validate manifests with `kops get --full` before `kops update`
- Report nil-subnet occurrences with valid specs as kOps bugs
When it happens
Trigger: RenderAWS invokes findExistingRouteTableForSubnet with a nil Subnet — e.g. a RouteTableAssociation task whose Subnet field was never populated (spec missing subnet reference, or prior task rendering failed silently).
Common situations: Cluster spec with a subnet association referencing a nonexistent/removed subnet; bugs in spec deserialization; partially-applied manifests where the Subnet task did not resolve.
Related errors
- --region is required (when --external)
- instance id for cloud instance member cannot be empty
- unknown load balancer Type: %q
- cannot mix egress values in private or IPv6-capable subnets
- creation of AWS Classic Load Balancers is no longer supporte
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/4d3f23c499f0f0a1.
Report an issue: GitHub.