mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 15:51:21 +00:00
Merge pull request #1792 from openziti/fix-timeout-err-check
Fix check for timeout error. Fixes #1791
This commit is contained in:
@@ -18,6 +18,7 @@ package handler_ctrl
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/router/env"
|
||||
"net"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -178,7 +179,7 @@ func (rh *routeHandler) connectEgress(msg *channel.Message, attempt int, ch chan
|
||||
switch {
|
||||
case errors.Is(err, syscall.ECONNREFUSED):
|
||||
errCode = ctrl_msg.ErrorTypeConnectionRefused
|
||||
case errors.Is(err, syscall.ETIMEDOUT):
|
||||
case isNetworkTimeout(err) || errors.Is(err, syscall.ETIMEDOUT):
|
||||
errCode = ctrl_msg.ErrorTypeDialTimedOut
|
||||
case errors.As(err, &xgress.MisconfiguredTerminatorError{}):
|
||||
errCode = ctrl_msg.ErrorTypeMisconfiguredTerminator
|
||||
@@ -200,6 +201,11 @@ func (rh *routeHandler) connectEgress(msg *channel.Message, attempt int, ch chan
|
||||
}
|
||||
}
|
||||
|
||||
func isNetworkTimeout(err error) bool {
|
||||
var netErr net.Error
|
||||
return errors.As(err, &netErr)
|
||||
}
|
||||
|
||||
func newDialParams(ctrlId string, route *ctrl_pb.Route, bindHandler xgress.BindHandler, logContext logcontext.Context, deadline time.Time) *dialParams {
|
||||
return &dialParams{
|
||||
ctrlId: ctrlId,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package handler_ctrl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type testTimeoutErr struct{}
|
||||
|
||||
func (t testTimeoutErr) Error() string {
|
||||
return "test"
|
||||
}
|
||||
|
||||
func (t testTimeoutErr) Timeout() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (t testTimeoutErr) Temporary() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func Test_TimeoutCheck(t *testing.T) {
|
||||
err := testTimeoutErr{}
|
||||
req := assert.New(t)
|
||||
req.True(isNetworkTimeout(err))
|
||||
|
||||
wrapped := fmt.Errorf("there was an error (%w)", err)
|
||||
req.True(isNetworkTimeout(wrapped))
|
||||
}
|
||||
Reference in New Issue
Block a user