Skip to content

Commit 88d9736

Browse files
authored
Merge pull request containerd#5027 from kevpar/config-check
Improve error detection when loading config
2 parents 2adb2ea + 5f051c1 commit 88d9736

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cmd/containerd/command/main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ can be used and modified as necessary as a custom configuration.`
114114
config = defaultConfig()
115115
)
116116

117-
if err := srvconfig.LoadConfig(context.GlobalString("config"), config); err != nil && !os.IsNotExist(err) {
118-
return err
117+
// Only try to load the config if it either exists, or the user explicitly
118+
// told us to load this path.
119+
configPath := context.GlobalString("config")
120+
_, err := os.Stat(configPath)
121+
if !os.IsNotExist(err) || context.GlobalIsSet("config") {
122+
if err := srvconfig.LoadConfig(configPath, config); err != nil {
123+
return err
124+
}
119125
}
120126

121127
// Apply flags to the config

0 commit comments

Comments
 (0)