Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit e376efd

Browse files
committed
use 'swarmctl' for 17.06 and estimate peers when we don't get ipam info
merge fcrisciani/ip-util-check:fix-peers-list and adamancini/ip-util-check:swarmctl
1 parent 565f27e commit e376efd

File tree

3 files changed

+57
-14
lines changed

3 files changed

+57
-14
lines changed

Dockerfile

+32-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1-
FROM ctelfer/swarmctl:latest
2-
RUN apk add --update bash docker jq
1+
FROM golang:1.11-alpine as build-swarmctl
2+
WORKDIR /go/src/github.com/docker
3+
4+
RUN apk add --no-cache --update bash ca-certificates curl make git openssh-client
5+
RUN git clone https://github.com/docker/swarmkit.git swarmkit && cd swarmkit && make bin/swarmctl && cp bin/swarmctl /usr/bin/swarmctl && rm -rf /go/src/github.com/docker/swarmkit
6+
7+
FROM alpine:3.9 as build-protoc
8+
ARG PROTOC_VERSION=3.6.1
9+
RUN apk add --update --no-cache unzip curl
10+
# download and install protoc binary and .proto files
11+
RUN curl --silent --show-error --location --output protoc.zip \
12+
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
13+
&& unzip -d /usr/local protoc.zip include/\* bin/\* \
14+
&& rm -f protoc.zip
15+
16+
FROM alpine:3.9 as build-docker
17+
ARG DOCKER_CLIENT_VERSION=18.09.1
18+
RUN apk add --update --no-cache curl
19+
RUN curl -SsL --output docker.tgz \
20+
https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLIENT_VERSION.tgz \
21+
&& tar xvzf docker.tgz \
22+
&& cp docker/docker /usr/bin/docker \
23+
&& rm -f docker.tgz
24+
25+
FROM alpine:3.9
26+
RUN apk add --no-cache --update bash jq
27+
# WORKDIR /go/src/github.com/docker
28+
# RUN git clone https://github.com/docker/swarmkit.git swarmkit && cd swarmkit && make bin/swarmctl && cp bin/swarmctl /usr/bin/swarmctl && rm -rf /go/src/github.com/docker/swarmkit
29+
COPY --from=build-swarmctl /usr/bin/swarmctl /usr/bin
30+
COPY --from=build-protoc /usr/local/. /usr/local
31+
COPY --from=build-docker /usr/bin/docker /usr/bin
332
COPY ip-util-check /usr/bin
4-
ENTRYPOINT [ "/usr/bin/ip-util-check" ]
33+
CMD [ "/usr/bin/ip-util-check" ]

README.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,29 @@ The script flags several potential conditions for each overlay:
2020
cluster size scales up to a certain number of nodes
2121
* IP address space is allocated to > 80% capacity
2222

23+
#### Note:
24+
Under certain conditions, it may not be possible to accurately
25+
count the number of IP addresses on a network due to Docker's
26+
networking state distribution architecture.
27+
28+
Gossip protocol only distributes network programming to nodes that
29+
participate in an overlay network. A node must have a container or
30+
service task scheduled on it attached to an overlay network to be
31+
considered an overlay network peer. Manager nodes that are not running
32+
workloads may not be able to accurately count the number of IP addresses
33+
on overlay networks scheduled on worker nodes. In this case, we approximate.
2334

2435
Building the Container
2536
======================
26-
docker image build -t docker/ip-util-check .
27-
37+
```
38+
docker build -t docker/ip-util-check .
39+
```
2840

2941
Running the Container
3042
=====================
31-
32-
docker run -it --rm \
33-
-v /var/run/docker.sock:/var/run/docker.sock \
34-
-v /var/run/docker/swarm/control.sock:/var/run/swarmd.sock \
35-
docker/ip-util-check
43+
```
44+
docker run -it --rm \
45+
-v /var/run/docker.sock:/var/run/docker.sock \
46+
-v /var/run/docker/swarm/control.sock:/var/run/swarmd.sock \
47+
docker/ip-util-check
48+
```

ip-util-check

+5-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ for net in $NETS ; do
6868
NET2NAME[$net]=$(echo $networkInspect | jq -r '.[].Name')
6969
set +e
7070
NET2SUB[$net]=$(echo $networkInspect | jq -r '.[].IPAM.Config[].Subnet' 2>/dev/null)
71-
if [ -z "${NET2SUB[$net]}" ] ; then
72-
NET2SUB[$net]=$(docker network inspect ${NET2NAME[$net]} | jq -r '.[].IPAM.Config[].Subnet' 2>/dev/null)
73-
fi
74-
set -e
71+
72+
if [ -z "${NET2SUB[$net]}" ] ; then
73+
NET2SUB[$net]=$(/usr/bin/swarmctl network inspect ${NET2NAME[$net]} | grep Subnet | awk -F ": " '{print $2}' 2>/dev/null)
74+
fi
75+
set -e
7576
NET2CAP[$net]=0
7677
NET2NCIP[$net]=0
7778
NET2NVIP[$net]=0

0 commit comments

Comments
 (0)