Skip to content

Commit

Permalink
Merge pull request #2696 from Luap99/ENOENT
Browse files Browse the repository at this point in the history
ignore ENOENT errors when parsing .d files
  • Loading branch information
mtrmac authored Jan 27, 2025
2 parents b5c6aff + 3f17e2e commit 7f0e59d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docker/registries_d.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package docker
import (
"errors"
"fmt"
"io/fs"
"net/url"
"os"
"path"
Expand Down Expand Up @@ -129,6 +130,11 @@ func loadAndMergeConfig(dirPath string) (*registryConfiguration, error) {
configPath := filepath.Join(dirPath, configName)
configBytes, err := os.ReadFile(configPath)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
// file must have been removed between the directory listing
// and the open call, ignore that as it is a expected race
continue
}
return nil, err
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/sysregistriesv2/system_registries_v2.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sysregistriesv2

import (
"errors"
"fmt"
"io/fs"
"os"
Expand Down Expand Up @@ -744,6 +745,11 @@ func tryUpdatingCache(ctx *types.SystemContext, wrapper configWrapper) (*parsedC
// Enforce v2 format for drop-in-configs.
dropIn, err := loadConfigFile(path, true)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
// file must have been removed between the directory listing
// and the open call, ignore that as it is a expected race
continue
}
return nil, fmt.Errorf("loading drop-in registries configuration %q: %w", path, err)
}
config.updateWithConfigurationFrom(dropIn)
Expand Down
10 changes: 4 additions & 6 deletions pkg/tlsclientconfig/tlsclientconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tlsclientconfig
import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -36,12 +37,9 @@ func SetupCertificates(dir string, tlsc *tls.Config) error {
logrus.Debugf(" crt: %s", fullPath)
data, err := os.ReadFile(fullPath)
if err != nil {
if os.IsNotExist(err) {
// Dangling symbolic link?
// Race with someone who deleted the
// file after we read the directory's
// list of contents?
logrus.Warnf("error reading certificate %q: %v", fullPath, err)
if errors.Is(err, os.ErrNotExist) {
// file must have been removed between the directory listing
// and the open call, ignore that as it is a expected race
continue
}
return err
Expand Down

0 comments on commit 7f0e59d

Please sign in to comment.