Skip to content

Commit 650461f

Browse files
mrclrchtrclaude
andcommitted
fix(network): skip worker IPv6 allocation when no workers exist
Previously, when creating a cluster with only control plane nodes (worker_count = 0), Terraform would still allocate 1 unused worker IPv6 primary IP. This caused "Primary IP limit exceeded" errors and wasted resources. Changes: - Worker IPv6: Use total_worker_count directly (no fallback to 1) - Worker private IPs: Remove unnecessary fallback for consistency - Aligns worker IPv6 behavior with worker IPv4 allocation Fixes #284 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b18ce22 commit 650461f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

network.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ resource "hcloud_primary_ip" "worker_ipv4" {
9797
}
9898

9999
resource "hcloud_primary_ip" "worker_ipv6" {
100-
count = var.enable_ipv6 ? local.total_worker_count > 0 ? local.total_worker_count : 1 : 0
100+
count = var.enable_ipv6 ? local.total_worker_count : 0
101101
name = "${local.cluster_prefix}worker-${count.index + 1}-ipv6"
102102
datacenter = data.hcloud_datacenter.this.name
103103
type = "ipv6"
@@ -139,6 +139,6 @@ locals {
139139
for index in range(var.control_plane_count > 0 ? var.control_plane_count : 1) : cidrhost(hcloud_network_subnet.nodes.ip_range, index + 101)
140140
]
141141
worker_private_ipv4_list = [
142-
for index in range(local.total_worker_count > 0 ? local.total_worker_count : 1) : cidrhost(hcloud_network_subnet.nodes.ip_range, index + 201)
142+
for index in range(local.total_worker_count) : cidrhost(hcloud_network_subnet.nodes.ip_range, index + 201)
143143
]
144144
}

0 commit comments

Comments
 (0)