Merge pull request #16668 from karta0807913/main

fix an override logic in Inherit function
This commit is contained in:
OpenShift Merge Robot
2022-12-06 17:58:31 -05:00
committed by GitHub
3 changed files with 55 additions and 4 deletions

View File

@ -614,8 +614,13 @@ func Inherit(infra libpod.Container, s *specgen.SpecGenerator, rt *libpod.Runtim
return nil, nil, nil, err
}
// podman pod container can override pod ipc NS
if !s.IpcNS.IsDefault() {
inheritSpec.IpcNS = s.IpcNS
}
// this causes errors when shmSize is the default value, it will still get passed down unless we manually override.
if s.IpcNS.NSMode == specgen.Host && (compatibleOptions.ShmSize != nil && compatibleOptions.IsDefaultShmSize()) {
if inheritSpec.IpcNS.NSMode == specgen.Host && (compatibleOptions.ShmSize != nil && compatibleOptions.IsDefaultShmSize()) {
s.ShmSize = nil
}
return options, infraSpec, compatibleOptions, nil

View File

@ -16,6 +16,7 @@ import (
"github.com/containers/common/libimage"
"github.com/containers/common/libnetwork/types"
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/parse"
"github.com/containers/common/pkg/secrets"
cutil "github.com/containers/common/pkg/util"
@ -148,6 +149,21 @@ type CtrSpecGenOptions struct {
func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) {
s := specgen.NewSpecGenerator(opts.Container.Image, false)
rtc, err := config.Default()
if err != nil {
return nil, err
}
if s.CgroupsMode == "" {
s.CgroupsMode = rtc.Cgroups()
}
if len(s.ImageVolumeMode) == 0 {
s.ImageVolumeMode = rtc.Engine.ImageVolumeMode
}
if s.ImageVolumeMode == "bind" {
s.ImageVolumeMode = "anonymous"
}
// pod name should be non-empty for Deployment objects to be able to create
// multiple pods having containers with unique names
if len(opts.PodName) < 1 {
@ -199,7 +215,7 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.InitContainerType = opts.InitContainerType
setupSecurityContext(s, opts.Container.SecurityContext, opts.PodSecurityContext)
err := setupLivenessProbe(s, opts.Container, opts.RestartPolicy)
err = setupLivenessProbe(s, opts.Container, opts.RestartPolicy)
if err != nil {
return nil, fmt.Errorf("failed to configure livenessProbe: %w", err)
}