Skip to content

Commit

Permalink
ignore ENOENT errors when parsing registries.conf.d files
Browse files Browse the repository at this point in the history
As always listing files in a dir to then read them is racy as the file
might have been removed in the meantime. Thus we must ignore ENOENT
errors when the file is opened.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Jan 27, 2025
1 parent 1294122 commit c9771a8
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit c9771a8

Please sign in to comment.