mirror of
https://github.com/containers/podman.git
synced 2025-10-20 20:54:45 +08:00
Merge pull request #7126 from mheon/fix_missing_ociruntime
Fix missing OCI Runtime
This commit is contained in:
@ -52,7 +52,7 @@ case "$CG_FS_TYPE" in
|
|||||||
if [[ "$OS_RELEASE_ID" == "ubuntu" ]]; then
|
if [[ "$OS_RELEASE_ID" == "ubuntu" ]]; then
|
||||||
echo "export OCI_RUNTIME=/usr/lib/cri-o-runc/sbin/runc" >> /etc/environment
|
echo "export OCI_RUNTIME=/usr/lib/cri-o-runc/sbin/runc" >> /etc/environment
|
||||||
else
|
else
|
||||||
echo "export OCI_RUNTIME=/usr/bin/runc" >> /etc/environment
|
echo "export OCI_RUNTIME=runc" >> /etc/environment
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -61,7 +61,7 @@ case "$CG_FS_TYPE" in
|
|||||||
# This is necessary since we've built/installed from source,
|
# This is necessary since we've built/installed from source,
|
||||||
# which uses runc as the default.
|
# which uses runc as the default.
|
||||||
warn "Forcing testing with crun instead of runc"
|
warn "Forcing testing with crun instead of runc"
|
||||||
echo "export OCI_RUNTIME=/usr/bin/crun" >> /etc/environment
|
echo "export OCI_RUNTIME=crun" >> /etc/environment
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) die_unknown CG_FS_TYPE
|
*) die_unknown CG_FS_TYPE
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package libpod
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"path/filepath"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -400,15 +400,31 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.
|
|||||||
// Handle legacy containers which might use a literal path for
|
// Handle legacy containers which might use a literal path for
|
||||||
// their OCI runtime name.
|
// their OCI runtime name.
|
||||||
runtimeName := ctr.config.OCIRuntime
|
runtimeName := ctr.config.OCIRuntime
|
||||||
if strings.HasPrefix(runtimeName, "/") {
|
|
||||||
runtimeName = filepath.Base(runtimeName)
|
|
||||||
}
|
|
||||||
|
|
||||||
ociRuntime, ok := s.runtime.ociRuntimes[runtimeName]
|
ociRuntime, ok := s.runtime.ociRuntimes[runtimeName]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
runtimeSet := false
|
||||||
|
|
||||||
|
// If the path starts with a / and exists, make a new
|
||||||
|
// OCI runtime for it using the full path.
|
||||||
|
if strings.HasPrefix(runtimeName, "/") {
|
||||||
|
if stat, err := os.Stat(runtimeName); err == nil && !stat.IsDir() {
|
||||||
|
newOCIRuntime, err := newConmonOCIRuntime(runtimeName, []string{runtimeName}, s.runtime.conmonPath, s.runtime.runtimeFlags, s.runtime.config)
|
||||||
|
if err == nil {
|
||||||
|
// The runtime lock should
|
||||||
|
// protect against concurrent
|
||||||
|
// modification of the map.
|
||||||
|
ociRuntime = newOCIRuntime
|
||||||
|
s.runtime.ociRuntimes[runtimeName] = ociRuntime
|
||||||
|
runtimeSet = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !runtimeSet {
|
||||||
// Use a MissingRuntime implementation
|
// Use a MissingRuntime implementation
|
||||||
ociRuntime = getMissingRuntime(runtimeName, s.runtime)
|
ociRuntime = getMissingRuntime(runtimeName, s.runtime)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctr.ociRuntime = ociRuntime
|
ctr.ociRuntime = ociRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -396,14 +396,12 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
|
|||||||
// If the string starts with / it's a path to a runtime
|
// If the string starts with / it's a path to a runtime
|
||||||
// executable.
|
// executable.
|
||||||
if strings.HasPrefix(runtime.config.Engine.OCIRuntime, "/") {
|
if strings.HasPrefix(runtime.config.Engine.OCIRuntime, "/") {
|
||||||
name := filepath.Base(runtime.config.Engine.OCIRuntime)
|
ociRuntime, err := newConmonOCIRuntime(runtime.config.Engine.OCIRuntime, []string{runtime.config.Engine.OCIRuntime}, runtime.conmonPath, runtime.runtimeFlags, runtime.config)
|
||||||
|
|
||||||
ociRuntime, err := newConmonOCIRuntime(name, []string{runtime.config.Engine.OCIRuntime}, runtime.conmonPath, runtime.runtimeFlags, runtime.config)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.ociRuntimes[name] = ociRuntime
|
runtime.ociRuntimes[runtime.config.Engine.OCIRuntime] = ociRuntime
|
||||||
runtime.defaultOCIRuntime = ociRuntime
|
runtime.defaultOCIRuntime = ociRuntime
|
||||||
} else {
|
} else {
|
||||||
ociRuntime, ok := runtime.ociRuntimes[runtime.config.Engine.OCIRuntime]
|
ociRuntime, ok := runtime.ociRuntimes[runtime.config.Engine.OCIRuntime]
|
||||||
|
|||||||
@ -235,14 +235,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
|
|||||||
|
|
||||||
ociRuntime := os.Getenv("OCI_RUNTIME")
|
ociRuntime := os.Getenv("OCI_RUNTIME")
|
||||||
if ociRuntime == "" {
|
if ociRuntime == "" {
|
||||||
var err error
|
ociRuntime = "crun"
|
||||||
ociRuntime, err = exec.LookPath("crun")
|
|
||||||
// If we cannot find the crun binary, setting to something static as we have no way
|
|
||||||
// to return an error. The tests will fail and point out that the runc binary could
|
|
||||||
// not be found nicely.
|
|
||||||
if err != nil {
|
|
||||||
ociRuntime = "/usr/bin/runc"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
os.Setenv("DISABLE_HC_SYSTEMD", "true")
|
os.Setenv("DISABLE_HC_SYSTEMD", "true")
|
||||||
CNIConfigDir := "/etc/cni/net.d"
|
CNIConfigDir := "/etc/cni/net.d"
|
||||||
|
|||||||
@ -51,14 +51,7 @@ func Setup(tempDir string) *EndpointTestIntegration {
|
|||||||
|
|
||||||
ociRuntime := os.Getenv("OCI_RUNTIME")
|
ociRuntime := os.Getenv("OCI_RUNTIME")
|
||||||
if ociRuntime == "" {
|
if ociRuntime == "" {
|
||||||
var err error
|
ociRuntime = "runc"
|
||||||
ociRuntime, err = exec.LookPath("runc")
|
|
||||||
// If we cannot find the runc binary, setting to something static as we have no way
|
|
||||||
// to return an error. The tests will fail and point out that the runc binary could
|
|
||||||
// not be found nicely.
|
|
||||||
if err != nil {
|
|
||||||
ociRuntime = "/usr/bin/runc"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
os.Setenv("DISABLE_HC_SYSTEMD", "true")
|
os.Setenv("DISABLE_HC_SYSTEMD", "true")
|
||||||
CNIConfigDir := "/etc/cni/net.d"
|
CNIConfigDir := "/etc/cni/net.d"
|
||||||
|
|||||||
@ -460,4 +460,17 @@ json-file | f
|
|||||||
is "$output" "$expect" "podman run with --tz=local, matches host"
|
is "$output" "$expect" "podman run with --tz=local, matches host"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# run with --runtime should preserve the named runtime
|
||||||
|
@test "podman run : full path to --runtime is preserved" {
|
||||||
|
skip_if_cgroupsv1
|
||||||
|
skip_if_remote
|
||||||
|
run_podman run -d --runtime '/usr/bin/crun' $IMAGE sleep 60
|
||||||
|
cid="$output"
|
||||||
|
|
||||||
|
run_podman inspect --format '{{.OCIRuntime}}' $cid
|
||||||
|
is "$output" "/usr/bin/crun"
|
||||||
|
|
||||||
|
run_podman kill $cid
|
||||||
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
|||||||
@ -253,6 +253,7 @@ function is_cgroupsv1() {
|
|||||||
! is_cgroupsv2
|
! is_cgroupsv2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# True if cgroups v2 are enabled
|
||||||
function is_cgroupsv2() {
|
function is_cgroupsv2() {
|
||||||
cgroup_type=$(stat -f -c %T /sys/fs/cgroup)
|
cgroup_type=$(stat -f -c %T /sys/fs/cgroup)
|
||||||
test "$cgroup_type" = "cgroup2fs"
|
test "$cgroup_type" = "cgroup2fs"
|
||||||
@ -305,6 +306,15 @@ function skip_if_no_selinux() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# skip_if_cgroupsv1 # ...with an optional message
|
||||||
|
#######################
|
||||||
|
function skip_if_cgroupsv1() {
|
||||||
|
if ! is_cgroupsv2; then
|
||||||
|
skip "${1:-test requires cgroupsv2}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#########
|
#########
|
||||||
# die # Abort with helpful message
|
# die # Abort with helpful message
|
||||||
#########
|
#########
|
||||||
|
|||||||
Reference in New Issue
Block a user