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

Remove containers/common/pkg/config from pkg/util #23857

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Sep 3, 2024

Does this PR introduce a user-facing change?

None

@rhatdan rhatdan added the No New Tests Allow PR to proceed without adding regression tests label Sep 3, 2024
@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 3, 2024
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Sep 3, 2024
@rhatdan
Copy link
Member Author

rhatdan commented Sep 3, 2024

@mtrmac is this what you are thinking?

Copy link
Collaborator

@mtrmac mtrmac left a 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?

@Luap99
Copy link
Member

Luap99 commented Sep 4, 2024

… 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 registry.PodmanConfig().ContainersConfDefaultsRO instead

For the other callers I would simply call config.Default() and handle the error there

@Luap99
Copy link
Member

Luap99 commented Sep 4, 2024

If the goal is to completely get rid of c/common/pkg/config from pkg/bindings it is much more work
graph

generated with goda graph "remote=1(reach(./pkg/bindings/...:all, github.com/containers/common/pkg/config))" | dot -Tsvg -o graph.svg assuming this tool is correct but the result looks fine to me on quick look

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@@ -20,7 +20,7 @@ var (
RunE: validate.SubCommandExists,
}

containerConfig = util.DefaultContainerConfig()
Copy link
Member

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

Comment on lines 16 to 17
logrus.Error(err)
os.Exit(1)
Copy link
Member

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()

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Sep 6, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Probably has to wait for V6

Signed-off-by: Daniel J Walsh <[email protected]>
Copy link
Collaborator

@mtrmac mtrmac left a 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.

@Luap99
Copy link
Member

Luap99 commented Sep 6, 2024

That is a known flake: #23685

@baude
Copy link
Member

baude commented Sep 17, 2024

/lgtm

thanks @rhatdan

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 17, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 62c1016 into containers:main Sep 17, 2024
82 checks passed
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Dec 17, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. No New Tests Allow PR to proceed without adding regression tests release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants