Skip to content

Commit

Permalink
Merge pull request #5027 from kevpar/config-check
Browse files Browse the repository at this point in the history
Improve error detection when loading config
  • Loading branch information
mxpv committed Feb 10, 2021
2 parents 2adb2ea + 5f051c1 commit 88d9736
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/containerd/command/main.go
Expand Up @@ -114,8 +114,14 @@ can be used and modified as necessary as a custom configuration.`
config = defaultConfig()
)

if err := srvconfig.LoadConfig(context.GlobalString("config"), config); err != nil && !os.IsNotExist(err) {
return err
// Only try to load the config if it either exists, or the user explicitly
// told us to load this path.
configPath := context.GlobalString("config")
_, err := os.Stat(configPath)
if !os.IsNotExist(err) || context.GlobalIsSet("config") {
if err := srvconfig.LoadConfig(configPath, config); err != nil {
return err
}
}

// Apply flags to the config
Expand Down

0 comments on commit 88d9736

Please sign in to comment.