Skip to content

Commit

Permalink
fix: Re-create tunnel if forwardsTo or appProto changes (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonstacks authored Nov 27, 2024
1 parent 984ca2a commit b8be5f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/tunneldriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b8be5f6

Please sign in to comment.