summaryrefslogtreecommitdiff
path: root/libpod/runtime_pod_infra_linux.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2021-01-04 15:29:18 -0500
committerMatthew Heon <mheon@redhat.com>2021-01-04 15:29:18 -0500
commit864592c74635aa91cef2e12224589b6446f9bb2d (patch)
tree41694a1a2abb6d21e2e05930a4130e6736c665ba /libpod/runtime_pod_infra_linux.go
parent46183cf8737d2b478923e16b545dce483c9b3d03 (diff)
downloadpodman-864592c74635aa91cef2e12224589b6446f9bb2d.tar.gz
podman-864592c74635aa91cef2e12224589b6446f9bb2d.tar.bz2
podman-864592c74635aa91cef2e12224589b6446f9bb2d.zip
Add default sysctls for pod infra containers
Ensure that infra containers for pods will grab default sysctls from containers.conf, to match how other containers are created. This mostly affects the other containers in the pod, which will inherit those sysctls when they join the pod's namespaces. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/runtime_pod_infra_linux.go')
-rw-r--r--libpod/runtime_pod_infra_linux.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go
index 3e4185db1..dd957527d 100644
--- a/libpod/runtime_pod_infra_linux.go
+++ b/libpod/runtime_pod_infra_linux.go
@@ -159,6 +159,34 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm
g.AddMount(devPts)
}
+ // Add default sysctls from containers.conf
+ defaultSysctls, err := util.ValidateSysctls(r.config.Sysctls())
+ if err != nil {
+ return nil, err
+ }
+ for sysctlKey, sysctlVal := range defaultSysctls {
+ // Ignore mqueue sysctls if not sharing IPC
+ if !p.config.UsePodIPC && strings.HasPrefix(sysctlKey, "fs.mqueue.") {
+ logrus.Infof("Sysctl %s=%s ignored in containers.conf, since IPC Namespace for pod is unused", sysctlKey, sysctlVal)
+
+ continue
+ }
+
+ // Ignore net sysctls if host network or not sharing network
+ if (p.config.InfraContainer.HostNetwork || !p.config.UsePodNet) && strings.HasPrefix(sysctlKey, "net.") {
+ logrus.Infof("Sysctl %s=%s ignored in containers.conf, since Network Namespace for pod is unused", sysctlKey, sysctlVal)
+ continue
+ }
+
+ // Ignore uts sysctls if not sharing UTS
+ if !p.config.UsePodUTS && (strings.HasPrefix(sysctlKey, "kernel.domainname") || strings.HasPrefix(sysctlKey, "kernel.hostname")) {
+ logrus.Infof("Sysctl %s=%s ignored in containers.conf, since UTS Namespace for pod is unused", sysctlKey, sysctlVal)
+ continue
+ }
+
+ g.AddLinuxSysctl(sysctlKey, sysctlVal)
+ }
+
containerName := p.ID()[:IDTruncLength] + "-infra"
options = append(options, r.WithPod(p))
options = append(options, WithRootFSFromImage(imgID, imgName, rawImageName))