@@ -12,6 +12,7 @@ import (
12
12
"github.com/docker/docker/testutil"
13
13
"github.com/docker/docker/testutil/daemon"
14
14
"github.com/moby/moby/api/types/network"
15
+ swarmtypes "github.com/moby/moby/api/types/swarm"
15
16
"github.com/vishvananda/netlink"
16
17
"gotest.tools/v3/assert"
17
18
is "gotest.tools/v3/assert/cmp"
@@ -494,3 +495,31 @@ func createBridge(t *testing.T, ifName string, addrs []string) net.IP {
494
495
}
495
496
return llAddr
496
497
}
498
+
499
+ // TestSwarmNoNftables checks that, because swarm does not yet have nftables support,
500
+ // it's not possible to:
501
+ // - enable Swarm when nftables is enabled, or to
502
+ // - restart an already Swarm enabled daemon with nftables enabled as well.
503
+ func TestSwarmNoNftables (t * testing.T ) {
504
+ ctx := testutil .StartSpan (baseContext , t )
505
+ skip .If (t , testEnv .IsRemoteDaemon )
506
+ skip .If (t , testEnv .IsRootless , "rootless mode doesn't support Swarm-mode" )
507
+
508
+ t .Run ("start" , func (t * testing.T ) {
509
+ d := daemon .New (t )
510
+ d .Start (t , "--firewall-backend=nftables" )
511
+ defer d .Stop (t )
512
+ err := d .SwarmInitWithError (ctx , t , swarmtypes.InitRequest {AdvertiseAddr : "127.0.0.1:2377" })
513
+ assert .Check (t , is .ErrorContains (err , "--firewall-backend=nftables is incompatible with swarm mode" ))
514
+ })
515
+
516
+ t .Run ("restart" , func (t * testing.T ) {
517
+ d := daemon .New (t )
518
+ d .Start (t , "--firewall-backend=iptables" )
519
+ defer d .Stop (t )
520
+ d .SwarmInit (ctx , t , swarmtypes.InitRequest {AdvertiseAddr : "127.0.0.1:2377" })
521
+
522
+ err := d .RestartWithError ("--firewall-backend=nftables" )
523
+ assert .Check (t , is .ErrorContains (err , "daemon exited during startup" ))
524
+ })
525
+ }
0 commit comments