Skip to content

Commit 0e1f8d8

Browse files
dilyevskyclaude
andcommitted
[cli] remove leader election from tunnel for per-pod connections
Each pod has its own netstack router with no shared state, so leader election was unnecessarily limiting the deployment to a single active tunnel connection. Every replica now independently connects to the tunnel server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f98bcca commit 0e1f8d8

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

pkg/cmd/run/tunnel.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,15 @@ func runTunnel(ctx context.Context, cfg *configv1alpha1.Config, tc *configv1alph
446446
tunScheme := runtime.NewScheme()
447447
utilruntime.Must(corev1alpha.Install(tunScheme))
448448

449-
mgr, err := ctrl.NewManager(kCluster, withLeaderElection(ctrl.Options{
449+
mgr, err := ctrl.NewManager(kCluster, ctrl.Options{
450450
Scheme: tunScheme,
451451
Metrics: metricsserver.Options{
452452
BindAddress: tc.MetricsAddr,
453453
},
454454
Cache: cache.Options{
455455
SyncPeriod: ptr.To(30 * time.Second),
456456
},
457-
}, "tunnel", runtimeNamespace(), tc.Name))
457+
})
458458
if err != nil {
459459
return fmt.Errorf("unable to set up controller manager: %w", err)
460460
}
@@ -482,28 +482,16 @@ func runTunnel(ctx context.Context, cfg *configv1alpha1.Config, tc *configv1alph
482482
return mgr.Start(gctx)
483483
})
484484

485-
// Only the elected replica should start the tunnel dataplane and bootstrap
486-
// its initial reconcile. Followers stay hot but idle for fast failover.
485+
// Start the router — each pod independently connects to the tunnel server.
487486
g.Go(func() error {
488-
select {
489-
case <-mgr.Elected():
490-
slog.Info("Acquired tunnel leadership", slog.String("tunnelNodeName", tn.Name))
491-
case <-gctx.Done():
492-
return gctx.Err()
493-
}
494-
495487
if err := r.Start(gctx); err != nil {
496488
slog.Error("Router exited with error", slog.Any("error", err))
497489
}
498490
return nil
499491
})
500492

493+
// Bootstrap initial reconcile after cache sync.
501494
g.Go(func() error {
502-
select {
503-
case <-mgr.Elected():
504-
case <-gctx.Done():
505-
return gctx.Err()
506-
}
507495
if !mgr.GetCache().WaitForCacheSync(gctx) {
508496
return gctx.Err()
509497
}

0 commit comments

Comments
 (0)