fix: skip external IPAM init in NAT mode — only pool mode needs per-VM allocation

In NAT mode, all VMs share a single gateway IP for SNAT. No per-VM
public IPs are allocated. Previously, external IPAM was initialized
for any external_mode != "", causing noisy AllocateIP failures (empty
pool range) on every instance launch.

Now IPAM is only initialized when external_mode == "pool". In NAT mode,
d.externalIPAM stays nil, cleanly skipping the auto-assign public IP
path. SNAT topology is still created by vpcd via the pool's gateway_ip.

Part of mulga-737 (Phase 16).
This commit is contained in:
Ben Duncan
2026-03-24 16:27:28 +10:00
parent a21a275776
commit ffca7330c5
+3 -2
View File
@@ -547,8 +547,9 @@ func (d *Daemon) Start() error {
return fmt.Errorf("failed to initialize VPC service: %w", err)
}
// Initialize external IPAM if external networking is configured
if d.clusterConfig != nil && d.clusterConfig.Network.ExternalMode != "" {
// Initialize external IPAM if pool mode is configured (per-VM public IPs).
// NAT mode only uses SNAT via a shared gateway IP — no per-VM allocation needed.
if d.clusterConfig != nil && d.clusterConfig.Network.ExternalMode == "pool" {
js, jsErr := d.natsConn.JetStream()
if jsErr != nil {
slog.Warn("Failed to get JetStream for external IPAM", "err", jsErr)