Skip to content

Commit 7f0e59d

Browse files
authored
Merge pull request #2696 from Luap99/ENOENT
ignore ENOENT errors when parsing .d files
2 parents b5c6aff + 3f17e2e commit 7f0e59d

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

docker/registries_d.go

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package docker
33
import (
44
"errors"
55
"fmt"
6+
"io/fs"
67
"net/url"
78
"os"
89
"path"
@@ -129,6 +130,11 @@ func loadAndMergeConfig(dirPath string) (*registryConfiguration, error) {
129130
configPath := filepath.Join(dirPath, configName)
130131
configBytes, err := os.ReadFile(configPath)
131132
if err != nil {
133+
if errors.Is(err, fs.ErrNotExist) {
134+
// file must have been removed between the directory listing
135+
// and the open call, ignore that as it is a expected race
136+
continue
137+
}
132138
return nil, err
133139
}
134140

pkg/sysregistriesv2/system_registries_v2.go

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sysregistriesv2
22

33
import (
4+
"errors"
45
"fmt"
56
"io/fs"
67
"os"
@@ -744,6 +745,11 @@ func tryUpdatingCache(ctx *types.SystemContext, wrapper configWrapper) (*parsedC
744745
// Enforce v2 format for drop-in-configs.
745746
dropIn, err := loadConfigFile(path, true)
746747
if err != nil {
748+
if errors.Is(err, fs.ErrNotExist) {
749+
// file must have been removed between the directory listing
750+
// and the open call, ignore that as it is a expected race
751+
continue
752+
}
747753
return nil, fmt.Errorf("loading drop-in registries configuration %q: %w", path, err)
748754
}
749755
config.updateWithConfigurationFrom(dropIn)

pkg/tlsclientconfig/tlsclientconfig.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tlsclientconfig
33
import (
44
"crypto/tls"
55
"crypto/x509"
6+
"errors"
67
"fmt"
78
"net"
89
"net/http"
@@ -36,12 +37,9 @@ func SetupCertificates(dir string, tlsc *tls.Config) error {
3637
logrus.Debugf(" crt: %s", fullPath)
3738
data, err := os.ReadFile(fullPath)
3839
if err != nil {
39-
if os.IsNotExist(err) {
40-
// Dangling symbolic link?
41-
// Race with someone who deleted the
42-
// file after we read the directory's
43-
// list of contents?
44-
logrus.Warnf("error reading certificate %q: %v", fullPath, err)
40+
if errors.Is(err, os.ErrNotExist) {
41+
// file must have been removed between the directory listing
42+
// and the open call, ignore that as it is a expected race
4543
continue
4644
}
4745
return err

0 commit comments

Comments
 (0)