Get rid of ipam modes in plugin-v2

plugin-v2 is not going to be used with Docker IPAM in most cases,
so there is no need to complicate the code with ipam mode selection.
This commit is contained in:
Martynas Pumputis authored and Bryan Boreham committed 2017-05-05 17:25:17 +00:00
1 parent 2ebd358aeb
commit d5d45de5a4
3 files changed
+6 -44

No files matched your search

+1 -22
View File
@@ -23,28 +23,8 @@ echo "Starting launch.sh"
# available to any plugin in general (https://github.com/moby/moby/issues/32815).
PEERS=
IPALLOC_INIT=
if [ ! -f "/restart.sentinel" ]; then
STATUS=0
/usr/bin/weaveutil is-swarm-manager 2>/dev/null || STATUS=$?
if [ $STATUS -eq 0 ]; then
IS_SWARM_MANAGER=1
elif [ $STATUS -eq 20 ]; then
echo "Host swarm is not \"active\"; exiting." >&2
exit 1
fi
SWARM_MANAGER_PEERS=$(/usr/bin/weaveutil swarm-manager-peers)
if [ -z "$IPALLOC_INIT" ]; then
IPALLOC_INIT="observer"
if [ "$IS_SWARM_MANAGER" == "1" ]; then
IPALLOC_INIT="consensus=$(echo $SWARM_MANAGER_PEERS | wc -l)"
fi
fi
PEERS=$(echo $SWARM_MANAGER_PEERS | tr '\n' ' ')
IPALLOC_INIT="--ipalloc-init $IPALLOC_INIT"
PEERS=$(/usr/bin/weaveutil swarm-manager-peers)
fi
router_bridge_opts() {
@@ -63,7 +43,6 @@ exec /home/weave/weaver $EXTRA_ARGS --port=6783 $(router_bridge_opts) \
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR \
--no-dns \
--ipalloc-range=$IPALLOC_RANGE \
$IPALLOC_INIT \
--nickname "$(hostname)" \
--log-level=debug \
--db-prefix="$WEAVE_DIR/weave" \
-1
View File
@@ -39,7 +39,6 @@ func init() {
"bridge-ip": bridgeIP,
"unique-id": uniqueID,
"swarm-manager-peers": swarmManagerPeers,
"is-swarm-manager": isSwarmManager,
"is-docker-plugin-enabled": isDockerPluginEnabled,
}
}
+5 -21
View File
@@ -2,48 +2,32 @@ package main
import (
"fmt"
"os"
"strings"
"github.com/docker/docker/api/types/swarm"
"github.com/fsouza/go-dockerclient"
"github.com/pkg/errors"
)
const DOCKER_API_VERSION = "1.26"
func isSwarmManager(args []string) error {
info, err := dockerInfo()
if err != nil {
return err
}
// hack-y way to denote that a node does not belong to any swarm
if info.Swarm.LocalNodeState != swarm.LocalNodeStateActive {
os.Exit(20)
}
if !info.Swarm.ControlAvailable {
return fmt.Errorf("node is not a manager")
}
return nil
}
func swarmManagerPeers(args []string) error {
info, err := dockerInfo()
if err != nil {
return err
}
ips := make([]string, 0)
for _, managerNode := range info.Swarm.RemoteManagers {
ip, err := ipFromAddr(managerNode.Addr)
if err != nil {
return errors.Wrap(err, "ipFromAddr")
}
fmt.Println(ip)
ips = append(ips, ip)
}
fmt.Println(strings.Join(ips, " "))
return nil
}