Merge pull request #488 from awh/486_administrative_peer_removal

Implement 'weave forget' command

Closes #486.
This commit is contained in:
rade committed 2015-03-27 01:53:16 +00:00
commit 245f747745
4 files changed
+30 -1

No files matched your search

+7
View File
@@ -52,6 +52,13 @@ func (cm *ConnectionMaker) InitiateConnection(address string) {
}
}
func (cm *ConnectionMaker) ForgetConnection(address string) {
cm.actionChan <- func() bool {
delete(cm.cmdLineAddress, NormalisePeerAddr(address))
return false
}
}
func (cm *ConnectionMaker) ConnectionTerminated(address string) {
cm.actionChan <- func() bool {
if target, found := cm.targets[address]; found {
+9 -1
View File
@@ -331,7 +331,15 @@ then on one of the existing hosts runs
host# weave connect $NEW_HOST
Other hosts in the weave network will automatically attempt to
establish connections to the new host too.
establish connections to the new host too. Conversely, it is possible
to instruct a peer to forget a particular host that was specified
to it via `weave launch` or `weave connect`:
host# weave forget $DECOMMISSIONED_HOST
This will prevent the peer from trying to reconnect to that host once
connectivity to it is lost, and thus can be used to administratively
remove decommissioned peers from the network.
### <a name="container-mobility"></a>Container mobility
+5
View File
@@ -18,6 +18,7 @@ usage() {
echo "weave launch [-password <password>] [-nickname <nickname>] <peer> ..."
echo "weave launch-dns <cidr>"
echo "weave connect <peer>"
echo "weave forget <peer>"
echo "weave run [--with-dns] <cidr> <docker run args> ..."
echo "weave start <cidr> <container_id>"
echo "weave attach <cidr> <container_id>"
@@ -597,6 +598,10 @@ case "$COMMAND" in
[ $# -eq 1 ] || usage
http_call $CONTAINER_NAME $HTTP_PORT POST /connect -d "peer=$1"
;;
forget)
[ $# -eq 1 ] || usage
http_call $CONTAINER_NAME $HTTP_PORT POST /forget -d "peer=$1"
;;
status)
http_call $CONTAINER_NAME $HTTP_PORT GET /status || true
echo
+9
View File
@@ -180,6 +180,15 @@ func handleHTTP(router *weave.Router) {
}
})
muxRouter.Methods("POST").Path("/forget").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
peer := r.FormValue("peer")
if addr, err := net.ResolveTCPAddr("tcp4", weave.NormalisePeerAddr(peer)); err == nil {
router.ConnectionMaker.ForgetConnection(addr.String())
} else {
http.Error(w, fmt.Sprint("invalid peer address: ", err), http.StatusBadRequest)
}
})
http.Handle("/", muxRouter)
address := fmt.Sprintf(":%d", weave.HTTPPort)