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

default: look up init binary in helper_binaries_dir #1115

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 14 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,20 @@ func (c *EngineConfig) findRuntime() string {
return ""
}

func (c *EngineConfig) findInit() string {
if _, err := os.Stat(DefaultInitPath); err == nil {
return DefaultInitPath
}
for _, dir := range c.HelperBinariesDir {
Copy link
Member

Choose a reason for hiding this comment

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

Can we use FindHelperBinary() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, missed that function. Yes we can use it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, this is a bit complicated without some slight refactoring I think.

We pick the init binary in EngineConfig, but there is no Config struct in scope for us to access FindHelperBinary. We could refactor FindHelperBinary to be below EngineConfig, as we only have two uses of them to find the network binaries, and they have access to both structs.

Else we keep the code as-is. Opinions?

Is there something I don't see here?

Copy link
Member

Choose a reason for hiding this comment

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

We can take a step back.

Why not create a public function InitPath() (string, error) that can be called by Podman? The logic would be similar to the current function but all data should be accessible at that point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would need to be InitPath(conf *config.Config) (string, error) right? You still want it to use the FindHelperBinary code from what I can tell.

Copy link
Member

Choose a reason for hiding this comment

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

@containers/podman-maintainers PTAL

Copy link
Member

Choose a reason for hiding this comment

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

@vrothberg the PR does not look like it has your suggested change?

Copy link
Member

Choose a reason for hiding this comment

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

@vrothberg Reminder...

Copy link
Member

Choose a reason for hiding this comment

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

Yes, needs change but I was looking for other opinions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't gotten around to taking a stab at the last suggestions sadly :/ I haven't forgotten about it, just need to find a little bit of time.

path := filepath.Join(dir, DefaultInitBinaryName)
if _, err := os.Stat(path); err == nil {
logrus.Debugf("Found init binary %s in helper binary directory %s", DefaultInitBinaryName, dir)
return path
}
}
return ""
}

// Validate is the main entry point for Engine configuration validation
// It returns an `error` on validation failure, otherwise
// `nil`.
Expand Down
6 changes: 5 additions & 1 deletion pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const (
)

var (
// DefaultInitBinaryName is the default name of the container-init binary.
// TODO: Expose this?
DefaultInitBinaryName = "catatonit"
// DefaultInitPath is the default path to the container-init binary.
DefaultInitPath = "/usr/libexec/podman/catatonit"
// DefaultInfraImage is the default image to run as infrastructure containers in pods.
Expand Down Expand Up @@ -381,7 +384,8 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
}
c.RuntimeSupportsNoCgroups = []string{"crun", "krun"}
c.RuntimeSupportsKVM = []string{"kata", "kata-runtime", "kata-qemu", "kata-fc", "krun"}
c.InitPath = DefaultInitPath
c.InitPath = c.findInit()

c.NoPivotRoot = false

c.InfraImage = DefaultInfraImage
Expand Down