Skip to content

Commit

Permalink
Merge pull request containers#20383 from Luap99/init-path
Browse files Browse the repository at this point in the history
use FindInitBinary() for init binary
  • Loading branch information
openshift-ci[bot] authored Oct 18, 2023
2 parents c73e99a + caef657 commit 62a81a1
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/podman/common/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
initPathFlagName := "init-path"
createFlags.StringVar(
&cf.InitPath,
initPathFlagName, initPath(),
initPathFlagName, "",
// Do not use the Value field for setting the default value to determine user input (i.e., non-empty string)
"Path to the container-init binary",
)
Expand Down
7 changes: 0 additions & 7 deletions cmd/podman/common/create_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ func Env() []string {
return nil
}

func initPath() string {
if !registry.IsRemote() {
return podmanConfig.ContainersConfDefaultsRO.InitPath()
}
return ""
}

func pidsLimit() int64 {
if !registry.IsRemote() {
return podmanConfig.ContainersConfDefaultsRO.PidsLimit()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.3.0
github.com/containers/buildah v1.32.1-0.20231016164031-ade05159a485
github.com/containers/common v0.56.1-0.20231017183641-80fb777f79e5
github.com/containers/common v0.56.1-0.20231018130318-493ab454c2af
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/gvisor-tap-vsock v0.7.1
github.com/containers/image/v5 v5.28.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ github.com/containernetworking/plugins v1.3.0 h1:QVNXMT6XloyMUoO2wUOqWTC1hWFV62Q
github.com/containernetworking/plugins v1.3.0/go.mod h1:Pc2wcedTQQCVuROOOaLBPPxrEXqqXBFt3cZ+/yVg6l0=
github.com/containers/buildah v1.32.1-0.20231016164031-ade05159a485 h1:RqgxHW2iP5QJ3aRahT+KGI2aGXVZeZHTeulmeZQV0y0=
github.com/containers/buildah v1.32.1-0.20231016164031-ade05159a485/go.mod h1:gOMfotERP5Gz2pN+AnuM3ephId/YL9DmbOtVck6fWfE=
github.com/containers/common v0.56.1-0.20231017183641-80fb777f79e5 h1:1y1a9x5eG+7E2yzb/KMGLg44xJQoFQExfSfIHW63EZ0=
github.com/containers/common v0.56.1-0.20231017183641-80fb777f79e5/go.mod h1:LM6Uyz5lq80P/DRnhs8NxvPIvBk2zmS2L/oednAGI/s=
github.com/containers/common v0.56.1-0.20231018130318-493ab454c2af h1:wjpdOCVcEtR+gfQXfyVxAftVlPnMdqWBVuJFZH62GkA=
github.com/containers/common v0.56.1-0.20231018130318-493ab454c2af/go.mod h1:LM6Uyz5lq80P/DRnhs8NxvPIvBk2zmS2L/oednAGI/s=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/gvisor-tap-vsock v0.7.1 h1:+Rc+sOPplrkQb/BUXeN0ug8TxjgyrIqo/9P/eNS2A4c=
Expand Down
4 changes: 2 additions & 2 deletions libpod/info_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/containers/common/libnetwork/pasta"
libpod "github.com/containers/common/libnetwork/slirp4netns"
"github.com/containers/common/libnetwork/slirp4netns"
"github.com/containers/common/pkg/apparmor"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/seccomp"
Expand Down Expand Up @@ -59,7 +59,7 @@ func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error {

slirp4netnsPath := r.config.Engine.NetworkCmdPath
if slirp4netnsPath == "" {
slirp4netnsPath, _ = r.config.FindHelperBinary(libpod.BinaryName, true)
slirp4netnsPath, _ = r.config.FindHelperBinary(slirp4netns.BinaryName, true)
}
if slirp4netnsPath != "" {
ver, err := version.Program(slirp4netnsPath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/specgen/generate/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
options = append(options, libpod.WithHostUsers(s.HostUsers))
}

command, err := makeCommand(s, imageData, rtc)
command, err := makeCommand(s, imageData)
if err != nil {
return nil, nil, nil, err
}
Expand Down
11 changes: 2 additions & 9 deletions pkg/specgen/generate/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/containers/common/libimage"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/specgen"
"github.com/opencontainers/runtime-tools/generate"
Expand All @@ -24,7 +23,7 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) {
}

// Produce the final command for the container.
func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData, rtc *config.Config) ([]string, error) {
func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData) ([]string, error) {
finalCommand := []string{}

entrypoint := s.Entrypoint
Expand All @@ -51,13 +50,7 @@ func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData, rtc *c
}

if s.Init {
initPath := s.InitPath
if initPath == "" && rtc != nil {
initPath = rtc.Engine.InitPath
}
if initPath == "" {
return nil, fmt.Errorf("no path to init binary found but container requested an init")
}
// bind mount for this binary is added in addContainerInitBinary()
finalCommand = append([]string{define.ContainerInitPath, "--"}, finalCommand...)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/specgen/generate/pause_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func buildPauseImage(rt *libpod.Runtime, rtConfig *config.Config) (string, error

// Also look into the path as some distributions install catatonit in
// /usr/bin.
catatonitPath, err := rtConfig.FindHelperBinary("catatonit", true)
catatonitPath, err := rtConfig.FindInitBinary()
if err != nil {
return "", fmt.Errorf("finding pause binary: %w", err)
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/specgen/generate/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ func finalizeMounts(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Ru
// If requested, add container init binary
if s.Init {
initPath := s.InitPath
if initPath == "" && rtc != nil {
initPath = rtc.Engine.InitPath
if initPath == "" {
initPath, err = rtc.FindInitBinary()
if err != nil {
return nil, nil, nil, fmt.Errorf("lookup init binary: %w", err)
}
}
initMount, err := addContainerInitBinary(s, initPath)
if err != nil {
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/containers/common/pkg/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions vendor/github.com/containers/common/pkg/config/default.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/pkg/volumes
github.com/containers/buildah/util
# github.com/containers/common v0.56.1-0.20231017183641-80fb777f79e5
# github.com/containers/common v0.56.1-0.20231018130318-493ab454c2af
## explicit; go 1.18
github.com/containers/common/libimage
github.com/containers/common/libimage/define
Expand Down

0 comments on commit 62a81a1

Please sign in to comment.