Skip to content

Handle forced connection closed by remote host error on Windows in release/1.1 branch #164

@austinvazquez

Description

@austinvazquez

Problem

When enabling CI on Windows for release/1.1 branch (#163), an edge case was found via unit tests when running on the latest Windows platform with Go 1.20+ toolchain.

=== RUN   TestOversizeCall
--- PASS: TestOversizeCall (0.03s)
=== RUN   TestClientEOF
    server_test.go:365: expected to have a cause of ErrClosed, got read unix @->TestClientEOF: wsarecv: An existing connection was forcibly closed by the remote host.
--- FAIL: TestClientEOF (0.00s)
=== RUN   TestServerRequestTimeout
--- PASS: TestServerRequestTimeout (0.01s)
=== RUN   TestServerConnectionsLeak
--- PASS: TestServerConnectionsLeak (0.10s)
=== RUN   Test_MethodFullNameGeneration
--- PASS: Test_MethodFullNameGeneration (0.00s)
FAIL
	github.com/containerd/ttrpc	coverage: 76.3% of statements
FAIL	github.com/containerd/ttrpc	1.696s
?   	github.com/containerd/ttrpc/cmd/protoc-gen-gogottrpc	[no test files]
?   	github.com/containerd/ttrpc/example	[no test files]
?   	github.com/containerd/ttrpc/example/cmd	[no test files]
?   	github.com/containerd/ttrpc/plugin	[no test files]
FAIL

The root cause is client not able to filter the connection closed by server error on Windows platform with the updated toolchain.
Ref:

ttrpc/client.go

Line 385 in 20c493e

func filterCloseErr(err error) error {

The impact is the client error does not get set to ErrClosed as expected.
Ref:

var ErrClosed = errors.New("ttrpc: closed")

Recommended Solution

The recommended solution would be to filter the error based on platform error using golang.org/x/sys package.

The solution should enable testing on Windows platform and existing TestClientEOF test should be sufficient to determine if issue is resolved.

Alternative solutions considered

Filter io.ErrClosedPIpe (Not viable)

This solution was to filter error closed on io.ErrClosedPipe.
Ref: https://github.com/containerd/ttrpc/blame/4a2816be9b4843f2cf40f1e533e7830d23f4489b/client.go#L450

Opened #165 and found this approach did not resolve the issue.

Filter based on error string

This solution would filter error closed based on the error string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions