You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
telco-ran: Pre-create /run/netns bindmount so it propagates to the container-mount-namespace
This closes a race between running `ip netns add` inside the
container-mount-namespace namespace and running it outside of the
container-mount-namespace namespace.
The cause of the race is that the /run/netns/ bindmount created by `ip
netns add` is created with rshared properties, so the external call
would shadow the internal call any time the internal call occurs first.
Forcing the call to happen on the outside ensures any subsequent
internal calls will simply reuse the existing bindmount (as intended).
Signed-off-by: Jim Ramsay <jramsay@redhat.com>
Copy file name to clipboardExpand all lines: telco-ran/configuration/extra-manifests-builder/01-container-mount-ns-and-kubelet-conf/container-mount-namespace.service
Copy file name to clipboardExpand all lines: telco-ran/configuration/kube-compare-reference/machine-config/kubelet-configuration-and-container-mount-hiding/01-container-mount-ns-and-kubelet-conf-master.yaml
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,16 @@ spec:
36
36
ExecStartPre=touch ${BIND_POINT}
37
37
ExecStart=unshare --mount=${BIND_POINT} --propagation slave mount --make-rshared /
38
38
ExecStop=umount -R ${RUNTIME_DIRECTORY}
39
+
40
+
# Initialize /run/netns as a shared mount point to prevent shadowing race condition
41
+
# This must happen before CRI-O starts to ensure all namespace bind mounts have
42
+
# the correct parent mount. Without this, 'ip netns add' (called later by network
43
+
# components) would create the mount point and shadow any earlier namespace mounts
44
+
# created by CRI-O's pinns, causing pods to fail with 'setns: Invalid argument'.
45
+
# This mirrors the mount setup that 'ip netns add' performs, but does it early.
46
+
# Reference: OCPBUGS-83562
47
+
ExecStartPost=bash -c "mkdir -p /run/netns"
48
+
ExecStartPost=bash -c 'if ! mountpoint -q /run/netns; then mount --rbind /run/netns /run/netns && mount --make-rshared /run/netns || { umount /run/netns 2>/dev/null; exit 1; }; fi'
Copy file name to clipboardExpand all lines: telco-ran/configuration/kube-compare-reference/machine-config/kubelet-configuration-and-container-mount-hiding/01-container-mount-ns-and-kubelet-conf-worker.yaml
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,16 @@ spec:
36
36
ExecStartPre=touch ${BIND_POINT}
37
37
ExecStart=unshare --mount=${BIND_POINT} --propagation slave mount --make-rshared /
38
38
ExecStop=umount -R ${RUNTIME_DIRECTORY}
39
+
40
+
# Initialize /run/netns as a shared mount point to prevent shadowing race condition
41
+
# This must happen before CRI-O starts to ensure all namespace bind mounts have
42
+
# the correct parent mount. Without this, 'ip netns add' (called later by network
43
+
# components) would create the mount point and shadow any earlier namespace mounts
44
+
# created by CRI-O's pinns, causing pods to fail with 'setns: Invalid argument'.
45
+
# This mirrors the mount setup that 'ip netns add' performs, but does it early.
46
+
# Reference: OCPBUGS-83562
47
+
ExecStartPost=bash -c "mkdir -p /run/netns"
48
+
ExecStartPost=bash -c 'if ! mountpoint -q /run/netns; then mount --rbind /run/netns /run/netns && mount --make-rshared /run/netns || { umount /run/netns 2>/dev/null; exit 1; }; fi'
0 commit comments