1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #719 from mrjana/bugs

Reconcile persistent state after driver config
This commit is contained in:
Madhu Venugopal 2015-10-29 05:56:40 +01:00
commit 31e6967d80
5 changed files with 52 additions and 15 deletions

View file

@ -225,6 +225,16 @@ func (d *dnetConnection) dnetDaemon(cfgFile string) error {
if err == nil { if err == nil {
cOptions = processConfig(cfg) cOptions = processConfig(cfg)
} }
bridgeConfig := options.Generic{
"EnableIPForwarding": true,
"EnableIPTables": true,
}
bridgeOption := options.Generic{netlabel.GenericData: bridgeConfig}
cOptions = append(cOptions, config.OptionDriverConfig("bridge", bridgeOption))
controller, err := libnetwork.New(cOptions...) controller, err := libnetwork.New(cOptions...)
if err != nil { if err != nil {
fmt.Println("Error starting dnetDaemon :", err) fmt.Println("Error starting dnetDaemon :", err)

View file

@ -338,16 +338,11 @@ func (c *networkConfiguration) conflictsWithNetworks(id string, others []*bridge
} }
func (d *driver) configure(option map[string]interface{}) error { func (d *driver) configure(option map[string]interface{}) error {
var config *configuration var (
var err error config *configuration
err error
err = d.initStore(option) natChain, filterChain *iptables.ChainInfo
if err != nil { )
return err
}
d.Lock()
defer d.Unlock()
genericData, ok := option[netlabel.GenericData] genericData, ok := option[netlabel.GenericData]
if !ok || genericData == nil { if !ok || genericData == nil {
@ -375,13 +370,23 @@ func (d *driver) configure(option map[string]interface{}) error {
} }
if config.EnableIPTables { if config.EnableIPTables {
d.natChain, d.filterChain, err = setupIPChains(config) natChain, filterChain, err = setupIPChains(config)
if err != nil { if err != nil {
return err return err
} }
} }
d.Lock()
d.natChain = natChain
d.filterChain = filterChain
d.config = config d.config = config
d.Unlock()
err = d.initStore(option)
if err != nil {
return err
}
return nil return nil
} }

View file

@ -20,6 +20,8 @@ function test_single_network_connectivity() {
# Now test connectivity between all the containers using service names # Now test connectivity between all the containers using service names
for i in `seq ${start} ${end}`; for i in `seq ${start} ${end}`;
do do
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) \
"ping -c 1 www.google.com"
for j in `seq ${start} ${end}`; for j in `seq ${start} ${end}`;
do do
if [ "$i" -eq "$j" ]; then if [ "$i" -eq "$j" ]; then
@ -49,6 +51,7 @@ function test_single_network_connectivity() {
test_single_network_connectivity bridge 3 test_single_network_connectivity bridge 3
} }
@test "Test default network dnet restart" { @test "Test default network dnet restart" {
skip_for_circleci skip_for_circleci

View file

@ -168,7 +168,8 @@ EOF
-v $(pwd)/${TMPC_ROOT}:/scratch \ -v $(pwd)/${TMPC_ROOT}:/scratch \
-v /usr/local/bin/runc:/usr/local/bin/runc \ -v /usr/local/bin/runc:/usr/local/bin/runc \
-w /go/src/github.com/docker/libnetwork \ -w /go/src/github.com/docker/libnetwork \
golang:1.4 ./cmd/dnet/dnet -d -D ${hopt} -c ${tomlfile} mrjana/golang ./cmd/dnet/dnet -d -D ${hopt} -c ${tomlfile}
wait_for_dnet $(inst_id2port ${inst}) ${name} wait_for_dnet $(inst_id2port ${inst}) ${name}
} }
@ -256,14 +257,16 @@ function stop_zookeeper() {
function test_overlay() { function test_overlay() {
dnet_suffix=$1 dnet_suffix=$1
shift
echo $(docker ps) echo $(docker ps)
start=1 start=1
end=3 end=3
# Setup overlay network and connect containers ot it # Setup overlay network and connect containers ot it
dnet_cmd $(inst_id2port 1) network create -d overlay multihost if [ -z "${2}" -o "${2}" != "skip_add" ]; then
dnet_cmd $(inst_id2port 1) network create -d overlay multihost
fi
for i in `seq ${start} ${end}`; for i in `seq ${start} ${end}`;
do do
dnet_cmd $(inst_id2port $i) container create container_${i} dnet_cmd $(inst_id2port $i) container create container_${i}
@ -273,6 +276,8 @@ function test_overlay() {
# Now test connectivity between all the containers using service names # Now test connectivity between all the containers using service names
for i in `seq ${start} ${end}`; for i in `seq ${start} ${end}`;
do do
runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) \
"ping -c 1 www.google.com"
for j in `seq ${start} ${end}`; for j in `seq ${start} ${end}`;
do do
if [ "$i" -eq "$j" ]; then if [ "$i" -eq "$j" ]; then
@ -290,7 +295,9 @@ function test_overlay() {
dnet_cmd $(inst_id2port $i) container rm container_${i} dnet_cmd $(inst_id2port $i) container rm container_${i}
done done
dnet_cmd $(inst_id2port 2) network rm multihost if [ -z "${2}" -o "${2}" != "skip_rm" ]; then
dnet_cmd $(inst_id2port 2) network rm multihost
fi
} }
function check_etchosts() { function check_etchosts() {

View file

@ -17,3 +17,15 @@ load helpers
skip_for_circleci skip_for_circleci
test_overlay_etchosts consul test_overlay_etchosts consul
} }
@test "Test overlay network with dnet restart" {
skip_for_circleci
test_overlay consul skip_rm
docker restart dnet-1-consul
wait_for_dnet $(inst_id2port 1) dnet-1-consul
docker restart dnet-2-consul
wait_for_dnet $(inst_id2port 2) dnet-2-consul
docker restart dnet-3-consul
wait_for_dnet $(inst_id2port 3) dnet-3-consul
test_overlay consul skip_add
}