-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Configuration file errors are hidden #25362
Comments
This is not an easy fix, generally speaking we abuse init() functions way to much and do to much work there. And we cannot parse the arguments earlier. But even if we would not use init() we still have a bit of a catch-22 between config parsing and cli parsing. The config contains options that influence the cli setup so we cannot parse the cli before the config. That means we cannot use the log-level argument to set the level during config parsing as that happened before. So I don't see how we would go about fixing that without introducing an even bigger mess. |
yes, IMO the init functions should not be used at all. Would it be possible to introduce a CONTAINER_LOGLEVEL env var that if set would call logrus.SetLevel from an init function somewhere deeply in the stack? It's not pretty, but would get the job done. |
A env var is an option, but then we still have to ensure somehow it is parsed first (easy enough if we just consider the config parsing code but not so much if we consider all imported packages). I think we still would need to fix the init() issues IMO so we have a sane order. Then there is the question if we actually want to commit to such an env var and maintain that in the log term, so far there never really was a need for it. And if we just do it as work around and then have different behavior between env and cli flag I think that makes things objectively worse for users to understand. |
Is there an issue somewhere that gives an overview of what the problems are? |
No, I don't have a issue but we have little to no control over the order of the imports and in what order init() runs. As such reading the env in one of them is to some extend undefined as the part before and after behave differently, the init() function that we run before still cannot log correctly. The proper fix is of course to not abuse init() and where it is needed or makes sense make sure to never log from that context. |
I don't mean the general problems of using init, but which podman dependencies (ab)use init, and where one could start to unravel the ball of yarn. |
The big thing are all the cobra command definitions in cmd/podman/... that setup the commands and flags. They in turn the call out to a bunch of other function, i.e. ones that trigger the config parsing and so on. I am not sure about other places, I fixed a few in the past. That said even if all the of the command/flag setup is moved to be called from main() there is still the problem that the flag setup needs the config values so we must read the file before we parsed --log-level so we don't gain that much. But adding and env would be a lot more simple then. I guess there is always the cheap hack, the current version uses special "remote" and "module" parsing in cmd/podman/registry to pass the option early, in theory one could try to do for log-level. But I really really hate this approach, it just feels so wrong to parse the same arguments several times to work around our bad code structure |
Issue Description
I was trying to get podman to recognize runc in a custom location, and had written an incorrect toml file.
The diagnostics (logrus.Tracef, logrus.Debugf calls) for this are emitted are sufficient, but as the configuration happens as global initialization, they are suppressed: processing the
--log-level
flag happens later.I looked for an env var to control this, but couldn't find one in the manpage.
I finally resolved it by recompiling podman and inserting a
logrus.SetLevel()
call invendor/github.com/containers/common/pkg/config/new.go
Steps to reproduce the issue
Describe the results you received
observe that nothing is printed about invalid keys:
Describe the results you expected
I wanted to see some of the diagnostic such as
podman info output
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
Additional environment details
Additional information
No response
The text was updated successfully, but these errors were encountered: