contiv / netplugin

Container networking for various use cases
Apache License 2.0
515 stars 178 forks source link

more ovs interfaces created than needed - thus when configuration is removed some configuration is not cleaned #49

Closed jainvipin closed 9 years ago

jainvipin commented 9 years ago

When I apply the following configuration

examples# cat one_host_multiple_nets.json 

{
    "Hosts" : [{
        "Name"                      : "host1",
        "Intf"                      : "eth1"
    }],
    "Tenants" : [{
        "Name"                      : "tenant-one",
        "DefaultNetType"            : "vlan",
        "SubnetPool"                : "11.1.0.0/16",
        "AllocSubnetLen"            : 24,
        "Vlans"                     : "11-28",
        "Networks"  : [
        {
            "Name"                  : "orange",
            "Endpoints" : [{
                "Container"         : "myContainer1",
                "Host"              : "host1"
            },
            {
                "Container"         : "myContainer2",
                "Host"              : "host1"
            }]
        },
        {
            "Name"                  : "purple",
            "Endpoints" : [{
                "Container"         : "myContainer3",
                "Host"              : "host1"
            },
            {
                "Container"         : "myContainer4",
                "Host"              : "host1"
            }]
        }]
    }]
}

examples# netdcli -cfg one_host_multiple_nets.json 
2015/04/09 03:39:24 updating the global config to new state &{{0xc208038030 } 0.01 tenant-one {11.1.0.0 16 24 11-28 } {vlan}} 

examples# ovs-vsctl show
b512d1eb-5bec-45e2-af96-2f34d66ebb29
    Manager "ptcp:6640"
        is_connected: true
    Bridge contivBridge
        Port "port5"
            tag: 12
            Interface "port5"
                type: internal
        Port "port40"
            tag: 11
            Interface "port40"
                type: internal
        Port "port4"
            tag: 12
            Interface "port4"
                type: internal
        Port "port2"
            tag: 11
            Interface "port2"
                type: internal
        Port "port39"
            tag: 11
            Interface "port39"
                type: internal
        Port "port41"
            tag: 12
            Interface "port41"
                type: internal
        Port "port42"
            tag: 12
            Interface "port42"
                type: internal
        Port "port3"
            tag: 11
            Interface "port3"
                type: internal
        Port "port1"
            Interface "eth1"
    ovs_version: "2.1.3"

It seems that that netplugin created 8 interfaces, where as actually it should have been only 4, because configuration suggests there are only 4 eps.

Thus later, when configuration is removed it leaves out approximately 4 interfaces in ovs. This can result into a leak that a perpetual operation can leak significant resources.

examples# netdcli -cfg none.json 
2015/04/09 03:39:49 error getting host id from hostIp  Subnet /0 err 'subnet length 0 not supported 
'
2015/04/09 03:39:49 error 'subnet length 0 not supported 
' deleting epid host1-native-intf 
2015/04/09 03:39:51 network not configured 
2015/04/09 03:39:51 error '100: Key not found (/contiv/master/config/nets/infra) [213066]' deleting net infra 
2015/04/09 03:39:51 freeing subnet 11.1.0.0/%!s(uint=24) 
2015/04/09 03:39:51 freeing subnet 11.1.1.0/%!s(uint=24) 
root@swvm174:~/go/src/github.com/contiv/examples# ovs-vsctl show
b512d1eb-5bec-45e2-af96-2f34d66ebb29
    Manager "ptcp:6640"
        is_connected: true
    Bridge contivBridge
        Port "port40"
            tag: 11
            Interface "port40"
                type: internal
        Port "port4"
            tag: 12
            Interface "port4"
                type: internal
        Port "port39"
            tag: 11
            Interface "port39"
                type: internal
        Port "port41"
            tag: 12
            Interface "port41"
                type: internal
    ovs_version: "2.1.3"
mapuri commented 9 years ago

@jainvipin

I am trying to reproduce the issue but I don't see the extra ports being created (as seen in output below) with the steps provided.

From your output about the extra ports (with port-numbers >39) I suspect that there might be other steps required to result into this condition. One of the things I can think of resulting in this is a missing state cleanup between start/restart of netplugin daemon. I suspect that netplugin was restarted in this case since the port's being created/cleaned up later had port numbers less than the left over ports. If that is the case, then I think the issue might be with how netplugin restores the state on a restart (i.e. with the cleanup script being run). I will try it out and see if I can repro.

vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$
vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$ netdcli -cfg examples/one
_host_multiple_nets.json
2015/05/13 17:17:28 gstate.go:405: updating the global config to new state &{{0xc208040030 } 0.01 tenant-one {11.1.0.0 16 24 11-28 } {vlan}}
vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$
vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$
vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$ ovs-vsctl show
2015-05-13T17:17:46Z|00001|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (Permission denied)
ovs-vsctl: unix:/var/run/openvswitch/db.sock: database connection failed (Permission denied)
vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$ sudo ovs-vsctl show
2bfd5ce9-a922-48b3-9a76-65e929639b9d
    Manager "ptcp:6640"
        is_connected: true
    Bridge contivBridge
        Port "port4"
            tag: 12
            Interface "port4"
                type: internal
        Port "port3"
            tag: 11
            Interface "port3"
                type: internal
        Port "port5"
            tag: 12
            Interface "port5"
                type: internal
        Port "port1"
            Interface "eth2"
        Port "port2"
            tag: 11
            Interface "port2"
                type: internal
    ovs_version: "2.0.2"
vagrant@netplugin-node1:/opt/golang/src/github.com/contiv/netplugin$
jainvipin commented 9 years ago

@mapuri - let me repro this and look at what's going on. thanks for trying it out in your setup

jainvipin commented 9 years ago

tried reproducing it few times with latest code, it doesn't happen - closing the issue