diff --git a/netmaster/master/network.go b/netmaster/master/network.go index d2b33cae1..c5f896221 100644 --- a/netmaster/master/network.go +++ b/netmaster/master/network.go @@ -177,6 +177,12 @@ func CreateNetwork(network intent.ConfigNetwork, stateDriver core.StateDriver, t return nil } + aci, _ := IsAciConfigured() + if aci { + // Skip docker network creation for ACI fabric mode. + return nil + } + if GetClusterMode() == "docker" { // Create the network in docker err = docknet.CreateDockNet(tenantName, network.Name, "", nwCfg) @@ -408,6 +414,12 @@ func DeleteNetworkID(stateDriver core.StateDriver, netID string) error { return err } + aci, _ := IsAciConfigured() + if aci { + // Skip docker network deletion for ACI fabric mode. + return nil + } + if nwCfg.NwType != "infra" { // For Infra nw, endpoint delete initiated by netplugin // Check if there are any active endpoints diff --git a/systemtests/aci_test.go b/systemtests/aci_test.go index e55023f74..e7b515f37 100755 --- a/systemtests/aci_test.go +++ b/systemtests/aci_test.go @@ -26,18 +26,27 @@ func (s *systemtestSuite) TestACIMode(c *C) { Encap: "vlan", }), IsNil) + err := s.nodes[0].checkDockerNetworkCreated("aciNet", false) + c.Assert(err, IsNil) + c.Assert(s.cli.EndpointGroupPost(&client.EndpointGroup{ TenantName: "default", NetworkName: "aciNet", GroupName: "epgA", }), IsNil) + err = s.nodes[0].checkDockerNetworkCreated("epgA", true) + c.Assert(err, IsNil) + c.Assert(s.cli.EndpointGroupPost(&client.EndpointGroup{ TenantName: "default", NetworkName: "aciNet", GroupName: "epgB", }), IsNil) + err = s.nodes[0].checkDockerNetworkCreated("epgB", true) + c.Assert(err, IsNil) + cA1, err := s.nodes[0].runContainer(containerSpec{networkName: "epgA"}) c.Assert(err, IsNil) diff --git a/systemtests/node_test.go b/systemtests/node_test.go index cf484da2c..dea65ee3e 100755 --- a/systemtests/node_test.go +++ b/systemtests/node_test.go @@ -112,6 +112,31 @@ func (n *node) cleanupDockerNetwork() error { return n.tbnode.RunCommand("docker network rm $(docker network ls | grep netplugin | awk '{print $2}')") } +func (n *node) checkDockerNetworkCreated(nwName string, expectedOp bool) error { + logrus.Infof("Checking whether docker network is created or not") + cmd := fmt.Sprintf("docker network ls | grep netplugin | grep %s | awk \"{print \\$2}\"", nwName) + logrus.Infof("Command to be executed is = %s", cmd) + op, err := n.tbnode.RunCommandWithOutput(cmd) + + if err == nil { + // if networks are NOT meant to be created. In ACI mode netctl net create should + // not create docker networks + ret := strings.Contains(op, nwName) + if expectedOp == false && ret != true { + logrus.Infof("Network names Input=%s and Output=%s are NOT matching and thats expected", nwName, op) + } else { + // If netwokrs are meant to be created. In ACI Once you create EPG, + // respective docker network should get created. + if ret == true { + logrus.Infof("Network names are matching.") + return nil + } + } + return nil + } + return err +} + func (n *node) cleanupContainers() error { logrus.Infof("Cleaning up containers on %s", n.Name()) if os.Getenv("ACI_SYS_TEST_MODE") == "ON" {