Skip to content

Commit 0cde94e

Browse files
committed
Address review comments
1 parent 9fb5773 commit 0cde94e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

controller/network/routesender.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func (self *routeSender) handleRouteSend(attempt uint32, path *model.Path, strat
189189
self.serviceCounters.ServiceDialOtherError(terminator.GetServiceId())
190190
failureCause = CircuitFailureRouterErrPortNotAllowed
191191
case ctrl_msg.ErrorTypeInvalidLinkDestination:
192+
self.serviceCounters.ServiceDialOtherError(terminator.GetServiceId())
192193
failureCause = CircuitFailureRouterErrInvalidLinkDest
193194
case ctrl_msg.ErrorTypeResourcesNotAvailable:
194195
self.serviceCounters.ServiceDialOtherError(terminator.GetServiceId())

router/handler_ctrl/classify_dial_error_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package handler_ctrl
1919
import (
2020
"fmt"
2121
"net"
22+
"os"
2223
"syscall"
2324
"testing"
2425

@@ -65,6 +66,15 @@ func Test_classifyDialError(t *testing.T) {
6566
require.Equal(t, byte(ctrl_msg.ErrorTypeDialTimedOut), classifyDialError(err))
6667
})
6768

69+
t.Run("timeout via net.OpError", func(t *testing.T) {
70+
err := &net.OpError{
71+
Op: "dial",
72+
Net: "tcp",
73+
Err: &os.SyscallError{Syscall: "connect", Err: syscall.ETIMEDOUT},
74+
}
75+
require.Equal(t, byte(ctrl_msg.ErrorTypeDialTimedOut), classifyDialError(err))
76+
})
77+
6878
t.Run("misconfigured terminator", func(t *testing.T) {
6979
err := xgress.MisconfiguredTerminatorError{InnerError: fmt.Errorf("bad address")}
7080
require.Equal(t, byte(ctrl_msg.ErrorTypeMisconfiguredTerminator), classifyDialError(err))

router/handler_ctrl/route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func classifyDialError(err error) byte {
197197
return ctrl_msg.ErrorTypeResourcesNotAvailable
198198
case isDnsError(err):
199199
return ctrl_msg.ErrorTypeDnsResolutionFailed
200-
case isNetworkTimeout(err) || errors.Is(err, syscall.ETIMEDOUT):
200+
case isNetworkTimeout(err):
201201
return ctrl_msg.ErrorTypeDialTimedOut
202202
case errors.As(err, &xgress.MisconfiguredTerminatorError{}):
203203
return ctrl_msg.ErrorTypeMisconfiguredTerminator
@@ -237,7 +237,7 @@ func isRejectedByApplicationError(err error) bool {
237237

238238
func isNetworkTimeout(err error) bool {
239239
var netErr net.Error
240-
return errors.As(err, &netErr)
240+
return (errors.As(err, &netErr) && netErr.Timeout()) || errors.Is(err, syscall.ETIMEDOUT)
241241
}
242242

243243
func newDialParams(ctrlId string, route *ctrl_pb.Route, bindHandler xgress.BindHandler, logContext logcontext.Context, deadline time.Time) *dialParams {

0 commit comments

Comments
 (0)