Skip to content

Commit

Permalink
Merge pull request weaveworks#3044 from weaveworks/check-disco-blank-…
Browse files Browse the repository at this point in the history
…token

Don't contact peer discovery back-end unless we have a token
  • Loading branch information
marccarre authored Jun 28, 2017
2 parents b79cc94 + 15c5123 commit fb7aa92
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions prog/weaver/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func peerDiscoveryDelete(discoveryEndpoint, token, peername string) error {

func HandleHTTPPeer(router *mux.Router, alloc *ipam.Allocator, discoveryEndpoint, token, peername string) {
router.Methods("DELETE").Path("/peer").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if discoveryEndpoint != "" {
if discoveryEndpoint != "" && token != "" {
if err := peerDiscoveryDelete(discoveryEndpoint, token, peername); err != nil {
Log.Errorf("Error while deleting self from peer discovery: %s", err)
}
Expand All @@ -90,7 +90,7 @@ func HandleHTTPPeer(router *mux.Router, alloc *ipam.Allocator, discoveryEndpoint

router.Methods("DELETE").Path("/peer/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ident := mux.Vars(r)["id"]
if discoveryEndpoint != "" {
if discoveryEndpoint != "" && token != "" {
// TODO: deal with this being either a peername or a nickname
if err := peerDiscoveryDelete(discoveryEndpoint, token, ident); err != nil {
Log.Errorf("Error while deleting self from peer discovery: %s", err)
Expand Down

0 comments on commit fb7aa92

Please sign in to comment.