Release Argo Tunnel Client 2018.3.8
This commit is contained in:
parent
d0a6a2a829
commit
5235d4cafa
|
@ -49,8 +49,8 @@ var launchdTemplate = ServiceTemplate{
|
||||||
<string>/tmp/%s.err.log</string>
|
<string>/tmp/%s.err.log</string>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NetworkState</key>
|
<key>SuccessfulExit</key>
|
||||||
<true/>
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
<key>ThrottleInterval</key>
|
<key>ThrottleInterval</key>
|
||||||
<integer>20</integer>
|
<integer>20</integer>
|
||||||
|
|
|
@ -11,8 +11,6 @@ import (
|
||||||
const (
|
const (
|
||||||
// Waiting time before retrying a failed tunnel connection
|
// Waiting time before retrying a failed tunnel connection
|
||||||
tunnelRetryDuration = time.Second * 10
|
tunnelRetryDuration = time.Second * 10
|
||||||
// Limit on the exponential backoff time period. (2^5 = 32 minutes)
|
|
||||||
tunnelRetryLimit = 5
|
|
||||||
// SRV record resolution TTL
|
// SRV record resolution TTL
|
||||||
resolveTTL = time.Hour
|
resolveTTL = time.Hour
|
||||||
)
|
)
|
||||||
|
@ -54,30 +52,31 @@ func (s *Supervisor) Run(ctx context.Context, connectedSignal chan struct{}) err
|
||||||
if err := s.initialize(ctx, connectedSignal); err != nil {
|
if err := s.initialize(ctx, connectedSignal); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tunnelsActive := s.config.HAConnections
|
var tunnelsWaiting []int
|
||||||
tunnelsWaiting := []int{}
|
|
||||||
backoff := BackoffHandler{MaxRetries: s.config.Retries, BaseTime: tunnelRetryDuration, RetryForever: true}
|
backoff := BackoffHandler{MaxRetries: s.config.Retries, BaseTime: tunnelRetryDuration, RetryForever: true}
|
||||||
var backoffTimer <-chan time.Time
|
var backoffTimer <-chan time.Time
|
||||||
for tunnelsActive > 0 {
|
|
||||||
|
for {
|
||||||
select {
|
select {
|
||||||
// Context cancelled
|
// Context cancelled
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
for tunnelsActive > 0 {
|
for len(s.tunnelErrors) > 0 {
|
||||||
<-s.tunnelErrors
|
<-s.tunnelErrors
|
||||||
tunnelsActive--
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
// startTunnel returned with error
|
// startTunnel returned with error
|
||||||
// (note that this may also be caused by context cancellation)
|
// (note that this may also be caused by context cancellation)
|
||||||
case tunnelError := <-s.tunnelErrors:
|
case tunnelError := <-s.tunnelErrors:
|
||||||
tunnelsActive--
|
|
||||||
if tunnelError.err != nil {
|
if tunnelError.err != nil {
|
||||||
Log.WithError(tunnelError.err).Warn("Tunnel disconnected due to error")
|
Log.WithError(tunnelError.err).Warn("Tunnel disconnected due to error")
|
||||||
tunnelsWaiting = append(tunnelsWaiting, tunnelError.index)
|
tunnelsWaiting = append(tunnelsWaiting, tunnelError.index)
|
||||||
s.waitForNextTunnel(tunnelError.index)
|
s.waitForNextTunnel(tunnelError.index)
|
||||||
|
|
||||||
if backoffTimer == nil {
|
if backoffTimer == nil {
|
||||||
backoffTimer = backoff.BackoffTimer()
|
backoffTimer = backoff.BackoffTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the error is a dial error, the problem is likely to be network related
|
// If the error is a dial error, the problem is likely to be network related
|
||||||
// try another addr before refreshing since we are likely to get back the
|
// try another addr before refreshing since we are likely to get back the
|
||||||
// same IPs in the same order. Same problem with duplicate connection error.
|
// same IPs in the same order. Same problem with duplicate connection error.
|
||||||
|
@ -93,7 +92,6 @@ func (s *Supervisor) Run(ctx context.Context, connectedSignal chan struct{}) err
|
||||||
for _, index := range tunnelsWaiting {
|
for _, index := range tunnelsWaiting {
|
||||||
go s.startTunnel(ctx, index, s.newConnectedTunnelSignal(index))
|
go s.startTunnel(ctx, index, s.newConnectedTunnelSignal(index))
|
||||||
}
|
}
|
||||||
tunnelsActive += len(tunnelsWaiting)
|
|
||||||
tunnelsWaiting = nil
|
tunnelsWaiting = nil
|
||||||
// Tunnel successfully connected
|
// Tunnel successfully connected
|
||||||
case <-s.nextConnectedSignal:
|
case <-s.nextConnectedSignal:
|
||||||
|
@ -113,7 +111,6 @@ func (s *Supervisor) Run(ctx context.Context, connectedSignal chan struct{}) err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("All tunnels terminated")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supervisor) initialize(ctx context.Context, connectedSignal chan struct{}) error {
|
func (s *Supervisor) initialize(ctx context.Context, connectedSignal chan struct{}) error {
|
||||||
|
@ -135,7 +132,7 @@ func (s *Supervisor) initialize(ctx context.Context, connectedSignal chan struct
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
<-s.tunnelErrors
|
<-s.tunnelErrors
|
||||||
// Error can't be nil. A nil error signals that initialization succeed
|
// Error can't be nil. A nil error signals that initialization succeed
|
||||||
return fmt.Errorf("Context was canceled")
|
return fmt.Errorf("context was canceled")
|
||||||
case tunnelError := <-s.tunnelErrors:
|
case tunnelError := <-s.tunnelErrors:
|
||||||
return tunnelError.err
|
return tunnelError.err
|
||||||
case <-connectedSignal:
|
case <-connectedSignal:
|
||||||
|
|
Loading…
Reference in New Issue