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:
1 parent
2ebd358aeb
commit
d5d45de5a4
3 files changed
+6
-44
No files matched your search
@@ -23,28 +23,8 @@ echo "Starting launch.sh"
|
|||||||
# available to any plugin in general (https://github.com/moby/moby/issues/32815).
|
# available to any plugin in general (https://github.com/moby/moby/issues/32815).
|
||||||
|
|
||||||
PEERS=
|
PEERS=
|
||||||
IPALLOC_INIT=
|
|
||||||
if [ ! -f "/restart.sentinel" ]; then
|
if [ ! -f "/restart.sentinel" ]; then
|
||||||
STATUS=0
|
PEERS=$(/usr/bin/weaveutil swarm-manager-peers)
|
||||||
/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"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
router_bridge_opts() {
|
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 \
|
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR \
|
||||||
--no-dns \
|
--no-dns \
|
||||||
--ipalloc-range=$IPALLOC_RANGE \
|
--ipalloc-range=$IPALLOC_RANGE \
|
||||||
$IPALLOC_INIT \
|
|
||||||
--nickname "$(hostname)" \
|
--nickname "$(hostname)" \
|
||||||
--log-level=debug \
|
--log-level=debug \
|
||||||
--db-prefix="$WEAVE_DIR/weave" \
|
--db-prefix="$WEAVE_DIR/weave" \
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ func init() {
|
|||||||
"bridge-ip": bridgeIP,
|
"bridge-ip": bridgeIP,
|
||||||
"unique-id": uniqueID,
|
"unique-id": uniqueID,
|
||||||
"swarm-manager-peers": swarmManagerPeers,
|
"swarm-manager-peers": swarmManagerPeers,
|
||||||
"is-swarm-manager": isSwarmManager,
|
|
||||||
"is-docker-plugin-enabled": isDockerPluginEnabled,
|
"is-docker-plugin-enabled": isDockerPluginEnabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-21
@@ -2,48 +2,32 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DOCKER_API_VERSION = "1.26"
|
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 {
|
func swarmManagerPeers(args []string) error {
|
||||||
info, err := dockerInfo()
|
info, err := dockerInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ips := make([]string, 0)
|
||||||
|
|
||||||
for _, managerNode := range info.Swarm.RemoteManagers {
|
for _, managerNode := range info.Swarm.RemoteManagers {
|
||||||
ip, err := ipFromAddr(managerNode.Addr)
|
ip, err := ipFromAddr(managerNode.Addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "ipFromAddr")
|
return errors.Wrap(err, "ipFromAddr")
|
||||||
}
|
}
|
||||||
fmt.Println(ip)
|
ips = append(ips, ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(strings.Join(ips, " "))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user