Skip to content

Commit d23c4b8

Browse files
committed
Use unix and windows specific connection error checks
Signed-off-by: Derek McGowan <[email protected]>
1 parent 02b6c69 commit d23c4b8

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

core/remotes/docker/resolver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"os"
2929
"path"
3030
"strings"
31-
"syscall"
3231

3332
"github.com/containerd/errdefs"
3433
"github.com/containerd/log"
@@ -778,7 +777,7 @@ func isTLSError(err error) bool {
778777
}
779778

780779
func isPortError(err error, host string) bool {
781-
if errors.Is(err, syscall.ECONNREFUSED) || os.IsTimeout(err) {
780+
if isConnError(err) || os.IsTimeout(err) {
782781
if _, port, _ := net.SplitHostPort(host); port != "" {
783782
// Port is specified, will not retry on different port with scheme change
784783
return false

core/remotes/docker/resolver_unix.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//go:build !windows
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package docker
20+
21+
import (
22+
"errors"
23+
"syscall"
24+
)
25+
26+
func isConnError(err error) bool {
27+
return errors.Is(err, syscall.ECONNREFUSED)
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//go:build windows
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package docker
20+
21+
import (
22+
"errors"
23+
"syscall"
24+
25+
"golang.org/x/sys/windows"
26+
)
27+
28+
func isConnError(err error) bool {
29+
return errors.Is(err, syscall.ECONNREFUSED) || errors.Is(err, windows.WSAECONNREFUSED)
30+
}

0 commit comments

Comments
 (0)