From b8be5f68f93ebdadd370aeda475a56be4005c57d Mon Sep 17 00:00:00 2001 From: Jonathan Stacks Date: Wed, 27 Nov 2024 07:08:02 -0800 Subject: [PATCH] fix: Re-create tunnel if forwardsTo or appProto changes (#527) --- pkg/tunneldriver/driver.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/tunneldriver/driver.go b/pkg/tunneldriver/driver.go index 88ce07d1..02416fa6 100644 --- a/pkg/tunneldriver/driver.go +++ b/pkg/tunneldriver/driver.go @@ -261,8 +261,14 @@ func (td *TunnelDriver) CreateTunnel(ctx context.Context, name string, spec ingr log := log.FromContext(ctx) if tun, ok := td.tunnels[name]; ok { - if maps.Equal(tun.Labels(), spec.Labels) { - log.Info("Tunnel labels match existing tunnel, doing nothing") + // Check if the tunnel matches the spec + var appProto string + if fwdProto, ok := tun.(interface{ ForwardsProto() string }); ok { + appProto = fwdProto.ForwardsProto() + } + + if maps.Equal(tun.Labels(), spec.Labels) && tun.ForwardsTo() == spec.ForwardsTo && appProto == spec.AppProtocol { + log.Info("Tunnel already exists and matches spec") return nil } // There is already a tunnel with this name, start the new one and defer closing the old one