mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-29 18:29:57 +00:00
TUN-3593: /ready endpoint for k8s readiness. Move tunnel events out of UI package, into connection package.
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/buildinfo"
|
||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/ui"
|
||||
"github.com/cloudflare/cloudflared/connection"
|
||||
"github.com/cloudflare/cloudflared/edgediscovery"
|
||||
"github.com/cloudflare/cloudflared/h2mux"
|
||||
@@ -65,7 +64,7 @@ type TunnelConfig struct {
|
||||
NamedTunnel *connection.NamedTunnelConfig
|
||||
ClassicTunnel *connection.ClassicTunnelConfig
|
||||
MuxerConfig *connection.MuxerConfig
|
||||
TunnelEventChan chan ui.TunnelEvent
|
||||
TunnelEventChans []chan connection.Event
|
||||
ProtocolSelector connection.ProtocolSelector
|
||||
EdgeTLSConfigs map[connection.Protocol]*tls.Config
|
||||
}
|
||||
@@ -235,10 +234,7 @@ func waitForBackoff(
|
||||
return err
|
||||
}
|
||||
|
||||
if config.TunnelEventChan != nil {
|
||||
config.TunnelEventChan <- ui.TunnelEvent{Index: connIndex, EventType: ui.Reconnecting}
|
||||
}
|
||||
|
||||
config.Observer.SendReconnect(connIndex)
|
||||
config.Logger.Infof("Retrying connection %d in %s seconds, error %v", connIndex, duration, err)
|
||||
protobackoff.Backoff(ctx)
|
||||
|
||||
@@ -288,12 +284,7 @@ func ServeTunnel(
|
||||
}
|
||||
}()
|
||||
|
||||
// If launch-ui flag is set, send disconnect msg
|
||||
if config.TunnelEventChan != nil {
|
||||
defer func() {
|
||||
config.TunnelEventChan <- ui.TunnelEvent{Index: connIndex, EventType: ui.Disconnected}
|
||||
}()
|
||||
}
|
||||
defer config.Observer.SendDisconnect(connIndex)
|
||||
|
||||
edgeConn, err := edgediscovery.DialEdge(ctx, dialTimeout, config.EdgeTLSConfigs[protocol], addr)
|
||||
if err != nil {
|
||||
|
@@ -47,6 +47,7 @@ func TestWaitForBackoffFallback(t *testing.T) {
|
||||
config := &TunnelConfig{
|
||||
Logger: logger,
|
||||
ProtocolSelector: protocolSelector,
|
||||
Observer: connection.NewObserver(nil, nil, false),
|
||||
}
|
||||
connIndex := uint8(1)
|
||||
|
||||
|
Reference in New Issue
Block a user