Use unix and windows specific connection error checks
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
parent
02b6c6939f
commit
d23c4b8b53
@ -28,7 +28,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/log"
|
||||
@ -778,7 +777,7 @@ func isTLSError(err error) bool {
|
||||
}
|
||||
|
||||
func isPortError(err error, host string) bool {
|
||||
if errors.Is(err, syscall.ECONNREFUSED) || os.IsTimeout(err) {
|
||||
if isConnError(err) || os.IsTimeout(err) {
|
||||
if _, port, _ := net.SplitHostPort(host); port != "" {
|
||||
// Port is specified, will not retry on different port with scheme change
|
||||
return false
|
||||
|
28
core/remotes/docker/resolver_unix.go
Normal file
28
core/remotes/docker/resolver_unix.go
Normal file
@ -0,0 +1,28 @@
|
||||
//go:build !windows
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func isConnError(err error) bool {
|
||||
return errors.Is(err, syscall.ECONNREFUSED)
|
||||
}
|
30
core/remotes/docker/resolver_windows.go
Normal file
30
core/remotes/docker/resolver_windows.go
Normal file
@ -0,0 +1,30 @@
|
||||
//go:build windows
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func isConnError(err error) bool {
|
||||
return errors.Is(err, syscall.ECONNREFUSED) || errors.Is(err, windows.WSAECONNREFUSED)
|
||||
}
|
Loading…
Reference in New Issue
Block a user