Skip to content

Commit 131458e

Browse files
Merge pull request #9423 from Luap99/rootless-cni-no-infra
rootless cni without infra container
2 parents 1c8d3d0 + d1e32dc commit 131458e

24 files changed

+1089
-1237
lines changed

.cirrus.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ apiv2_test_task:
440440
time_script: '$SCRIPT_BASE/logcollector.sh time'
441441

442442
compose_test_task:
443-
name: "compose test on $DISTRO_NV"
443+
name: "compose test on $DISTRO_NV ($PRIV_NAME)"
444444
alias: compose_test
445445
only_if: *not_docs
446446
skip: *tags
@@ -450,6 +450,11 @@ compose_test_task:
450450
env:
451451
<<: *stdenvars
452452
TEST_FLAVOR: compose
453+
matrix:
454+
- env:
455+
PRIV_NAME: root
456+
- env:
457+
PRIV_NAME: rootless
453458
clone_script: *noop # Comes from cache
454459
gopath_cache: *ro_gopath_cache
455460
setup_script: *setup

contrib/cirrus/runner.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,6 @@ dotest() {
288288
exec_container # does not return
289289
fi;
290290
291-
# shellcheck disable=SC2154
292-
if [[ "$PRIV_NAME" == "rootless" ]] && [[ "$UID" -eq 0 ]]; then
293-
req_env_vars ROOTLESS_USER
294-
msg "Re-executing runner through ssh as user '$ROOTLESS_USER'"
295-
msg "************************************************************"
296-
set -x
297-
exec ssh $ROOTLESS_USER@localhost \
298-
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
299-
-o CheckHostIP=no $GOSRC/$SCRIPT_BASE/runner.sh
300-
# does not return
301-
fi
302-
303291
# containers/automation sets this to 0 for its dbg() function
304292
# but the e2e integration tests are also sensitive to it.
305293
unset DEBUG
@@ -340,6 +328,19 @@ msg "************************************************************"
340328
((${SETUP_ENVIRONMENT:-0})) || \
341329
die "Expecting setup_environment.sh to have completed successfully"
342330
331+
# shellcheck disable=SC2154
332+
if [[ "$PRIV_NAME" == "rootless" ]] && [[ "$UID" -eq 0 ]]; then
333+
req_env_vars ROOTLESS_USER
334+
msg "Re-executing runner through ssh as user '$ROOTLESS_USER'"
335+
msg "************************************************************"
336+
set -x
337+
exec ssh $ROOTLESS_USER@localhost \
338+
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
339+
-o CheckHostIP=no $GOSRC/$SCRIPT_BASE/runner.sh
340+
# Does not return!
341+
fi
342+
# else: not running rootless, do nothing special
343+
343344
cd "${GOSRC}/"
344345
345346
handler="_run_${TEST_FLAVOR}"

contrib/rootless-cni-infra/Containerfile

Lines changed: 0 additions & 36 deletions
This file was deleted.

contrib/rootless-cni-infra/README.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

contrib/rootless-cni-infra/rootless-cni-infra

Lines changed: 0 additions & 181 deletions
This file was deleted.

libpod/container_internal.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,7 @@ func (c *Container) completeNetworkSetup() error {
966966
if err := c.syncContainer(); err != nil {
967967
return err
968968
}
969-
if rootless.IsRootless() {
970-
return c.runtime.setupRootlessNetNS(c)
971-
} else if c.config.NetMode.IsSlirp4netns() {
969+
if c.config.NetMode.IsSlirp4netns() {
972970
return c.runtime.setupSlirp4netns(c)
973971
}
974972
if err := c.runtime.setupNetNS(c); err != nil {

libpod/container_internal_linux.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ func (c *Container) prepare() error {
9292
// Set up network namespace if not already set up
9393
noNetNS := c.state.NetNS == nil
9494
if c.config.CreateNetNS && noNetNS && !c.config.PostConfigureNetNS {
95-
if rootless.IsRootless() && len(c.config.Networks) > 0 {
96-
netNS, networkStatus, createNetNSErr = AllocRootlessCNI(context.Background(), c)
97-
} else {
98-
netNS, networkStatus, createNetNSErr = c.runtime.createNetNS(c)
99-
}
95+
netNS, networkStatus, createNetNSErr = c.runtime.createNetNS(c)
10096
if createNetNSErr != nil {
10197
return
10298
}

libpod/network/create.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/containernetworking/cni/pkg/version"
1212
"github.com/containers/common/pkg/config"
1313
"github.com/containers/podman/v3/pkg/domain/entities"
14-
"github.com/containers/podman/v3/pkg/rootless"
1514
"github.com/containers/podman/v3/pkg/util"
1615
"github.com/pkg/errors"
1716
"github.com/sirupsen/logrus"
@@ -223,9 +222,8 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
223222
plugins = append(plugins, NewPortMapPlugin())
224223
plugins = append(plugins, NewFirewallPlugin())
225224
plugins = append(plugins, NewTuningPlugin())
226-
// if we find the dnsname plugin or are rootless, we add configuration for it
227-
// the rootless-cni-infra container has the dnsname plugin always installed
228-
if (HasDNSNamePlugin(runtimeConfig.Network.CNIPluginDirs) || rootless.IsRootless()) && !options.DisableDNS {
225+
// if we find the dnsname plugin we add configuration for it
226+
if HasDNSNamePlugin(runtimeConfig.Network.CNIPluginDirs) && !options.DisableDNS {
229227
if options.Internal {
230228
logrus.Warnf("dnsname and --internal networks are incompatible. dnsname plugin not configured for network %s", name)
231229
} else {

0 commit comments

Comments
 (0)