-
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
Remove containers/common/pkg/config from pkg/util #23857
Conversation
@mtrmac is this what you are thinking? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtrmac is this what you are thinking?
Something vaguely along these lines.
AFAICS this doesn’t work yet because …/podman/v5/util
is also included by vendor/github.com/containers/podman/v5/pkg/bindings/containers/create.go
, per
package main
import (
_ "github.com/containers/podman/v5/pkg/bindings"
_ "github.com/containers/podman/v5/pkg/bindings/containers"
_ "github.com/containers/podman/v5/pkg/bindings/generate"
_ "github.com/containers/podman/v5/pkg/bindings/images"
_ "github.com/containers/podman/v5/pkg/bindings/kube"
_ "github.com/containers/podman/v5/pkg/bindings/manifests"
_ "github.com/containers/podman/v5/pkg/bindings/network"
_ "github.com/containers/podman/v5/pkg/bindings/play"
_ "github.com/containers/podman/v5/pkg/bindings/pods"
_ "github.com/containers/podman/v5/pkg/bindings/secrets"
_ "github.com/containers/podman/v5/pkg/bindings/system"
_ "github.com/containers/podman/v5/pkg/bindings/volumes"
)
func main() {
}
in a new directory + go mod tidy && go mod vendor
and inspecting the result.
I didn’t check further how deep the rabbit hole goes; it might involve several more package splits. Or it might not.
We got here by having a jack-of-all-trades pkg/util
package; I don’t think moving the code into a different utils
package is structurally an improvement. Move that into a separate internal/config
(or maybe pkg/config
? I think internal
would be cleaner but it’s also not widely used).
That’s clearly not this PR, but the Podman codebase has 29 other calls to config.Default()
. If we have an init
that exists on failure, it seems to me those 29 calls could be migrated to DefaultContainerConfig
and we could remove some handling of unreachable errors.
… or maybe not? config.Reload
exists… and if I am skimming the code correctly, that affects config.Default()
but not DefaultContainerConfig()
. I don’t understand what is going on. Maybe DefaultContainerConfig
should not exist at all?
Agreed, at least in the cmd/podman dirs one should use For the other callers I would simply call config.Default() and handle the error there |
Ephemeral COPR build failed. @containers/packit-build please check. |
@@ -20,7 +20,7 @@ var ( | |||
RunE: validate.SubCommandExists, | |||
} | |||
|
|||
containerConfig = util.DefaultContainerConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use registry.PodmanConfig().ContainersConfDefaultsRO
in all cmd/podman/... files instead
internal/config/config.go
Outdated
logrus.Error(err) | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really think this is just a miss feature abusing init(). Of course it is a pre existing issue but this doesn't feel right at all. For starters exit code 1 is wrong as we document 125 as default exit code. But in general storing a copy of the config is just wrong.
So please just convert all the callers to config.Default()
and handle the errors there. As @mtrmac pointed this here does not work with config.Reload()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Probably has to wait for V6 Signed-off-by: Daniel J Walsh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, this is clearly an improvement.
The test failure looks rather worrisome:
$ podman [options] stop --all -t 0
SIGABRT: abort
PC=0x40cd0e m=0 sigcode=0
with nothing obvious in the backtrace.
That is a known flake: #23685 |
/lgtm thanks @rhatdan |
Does this PR introduce a user-facing change?