aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-21 14:38:07 -0400
committerGitHub <noreply@github.com>2020-09-21 14:38:07 -0400
commitdc5cc4356362274325a5b4fb2ba8ce71b12544dd (patch)
tree7cafb88fedeffa9dec2f586f0ae24c6631a37bfd
parent051912c8e6998047d31cb7b8330ffcf65a4ead40 (diff)
parentcaad1020563beabe6d91b13cdaade26d3666cb0c (diff)
downloadpodman-dc5cc4356362274325a5b4fb2ba8ce71b12544dd.tar.gz
podman-dc5cc4356362274325a5b4fb2ba8ce71b12544dd.tar.bz2
podman-dc5cc4356362274325a5b4fb2ba8ce71b12544dd.zip
Merge pull request #7698 from AkihiroSuda/rootless-cni-deflake-lo-up
rootless-cni-infra: fix flakiness during bringing up lo interface
-rw-r--r--contrib/rootless-cni-infra/Containerfile2
-rwxr-xr-xcontrib/rootless-cni-infra/rootless-cni-infra18
-rw-r--r--libpod/rootless_cni_linux.go2
3 files changed, 20 insertions, 2 deletions
diff --git a/contrib/rootless-cni-infra/Containerfile b/contrib/rootless-cni-infra/Containerfile
index 5be30ccc9..6bf70d644 100644
--- a/contrib/rootless-cni-infra/Containerfile
+++ b/contrib/rootless-cni-infra/Containerfile
@@ -34,4 +34,4 @@ COPY rootless-cni-infra /usr/local/bin
ENV CNI_PATH=/opt/cni/bin
CMD ["sleep", "infinity"]
-ENV ROOTLESS_CNI_INFRA_VERSION=1
+ENV ROOTLESS_CNI_INFRA_VERSION=2
diff --git a/contrib/rootless-cni-infra/rootless-cni-infra b/contrib/rootless-cni-infra/rootless-cni-infra
index f6622b23c..5cb43621d 100755
--- a/contrib/rootless-cni-infra/rootless-cni-infra
+++ b/contrib/rootless-cni-infra/rootless-cni-infra
@@ -4,6 +4,23 @@ set -eu
ARG0="$0"
BASE="/run/rootless-cni-infra"
+wait_unshare_net() {
+ pid="$1"
+ # NOTE: busybox shell doesn't support the `for ((i=0; i < $MAX; i++)); do foo; done` statement
+ i=0
+ while :; do
+ if [ "$(readlink /proc/self/ns/net)" != "$(readlink /proc/${pid}/ns/net)" ]; then
+ break
+ fi
+ sleep 0.1
+ if [ $i -ge 10 ]; then
+ echo >&2 "/proc/${pid}/ns/net cannot be unshared"
+ exit 1
+ fi
+ i=$((i + 1))
+ done
+}
+
# CLI subcommand: "alloc $CONTAINER_ID $NETWORK_NAME $POD_NAME"
cmd_entrypoint_alloc() {
if [ "$#" -ne 3 ]; then
@@ -24,6 +41,7 @@ cmd_entrypoint_alloc() {
else
unshare -n sleep infinity &
pid="$!"
+ wait_unshare_net "${pid}"
echo "${pid}" >"${dir}/pid"
nsenter -t "${pid}" -n ip link set lo up
fi
diff --git a/libpod/rootless_cni_linux.go b/libpod/rootless_cni_linux.go
index 7feec6b44..2877191e5 100644
--- a/libpod/rootless_cni_linux.go
+++ b/libpod/rootless_cni_linux.go
@@ -25,7 +25,7 @@ import (
// Built from ../contrib/rootless-cni-infra.
var rootlessCNIInfraImage = map[string]string{
- "amd64": "quay.io/libpod/rootless-cni-infra@sha256:8aa681c4c08dee3ec5d46ff592fddd0259a35626717006d6b77ee786b1d02967", // 1-amd64
+ "amd64": "quay.io/libpod/rootless-cni-infra@sha256:e92c3a6367f8e554121b96d39af1f19f0f9ac5a32922b290112e13bc661d3a29", // 2-amd64
}
const (