Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full path for error messages on containers.conf #164

Merged
merged 1 commit into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,16 @@ func Default() (*Config, error) {
})
return config, err
}

func Path() string {
if path := os.Getenv("CONTAINERS_CONF"); path != "" {
return path
}
if unshare.IsRootless() {
if rpath, err := rootlessConfigPath(); err == nil {
return rpath
}
return "$HOME/" + UserOverrideContainersConfig
}
return OverrideContainersConfig
}
4 changes: 2 additions & 2 deletions pkg/config/libpodConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func newLibpodConfig(c *Config) error {

// hard code EventsLogger to "file" to match older podman versions.
if config.EventsLogger != "file" {
logrus.Debugf("Ignoring lipod.conf EventsLogger setting %q. Use containers.conf if you want to change this setting and remove libpod.conf files.", config.EventsLogger)
logrus.Debugf("Ignoring libpod.conf EventsLogger setting %q. Use %q if you want to change this setting and remove libpod.conf files.", Path(), config.EventsLogger)
config.EventsLogger = "file"
}

Expand Down Expand Up @@ -262,7 +262,7 @@ func systemLibpodConfigs() ([]string, error) {
}
// TODO: Raise to Warnf, when Podman is updated to
// remove libpod.conf by default
logrus.Debugf("Found deprecated file %s, please remove. Use %s to override defaults.\n", path, containersConfPath)
logrus.Debugf("Found deprecated file %s, please remove. Use %s to override defaults.\n", Path(), containersConfPath)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the function Path is only used for logging but not the code path actually loading the configs, which might lead to a different path being logged and loaded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes, but the code that does the actual search is also going to use /usr/share/containers/containers.conf for reading the distro configuration. But we don't want to indicate to users that they should use that configuration.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

return []string{path}, nil
}
return nil, err
Expand Down