Skip to content

Commit

Permalink
Merge pull request #5594 from oldmantaiter/fix/lease-redirect
Browse files Browse the repository at this point in the history
Fix for lease redirect
  • Loading branch information
e-dard committed Feb 9, 2016
2 parents a9552fd + 63ff0ca commit f2c6a45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- [#5182](https://github.com/influxdata/influxdb/pull/5182): Graphite: Fix an issue where the default template would be used instead of a more specific one. Thanks @flisky
- [#5489](https://github.com/influxdata/influxdb/pull/5489): Fixes multiple issues causing tests to fail on windows. Thanks @runner-mei
- [#5594](https://github.com/influxdata/influxdb/pull/5594): Fix missing url params on lease redirect - @oldmantaiter

## v0.10.0 [2016-02-04]

Expand Down
33 changes: 18 additions & 15 deletions services/meta/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,23 @@ func (h *handler) servePing(w http.ResponseWriter, r *http.Request) {

// serveLease
func (h *handler) serveLease(w http.ResponseWriter, r *http.Request) {
var name, nodeIDStr string
q := r.URL.Query()

// Get the requested lease name.
name = q.Get("name")
if name == "" {
http.Error(w, "lease name required", http.StatusBadRequest)
return
}

// Get the ID of the requesting node.
nodeIDStr = q.Get("nodeid")
if nodeIDStr == "" {
http.Error(w, "node ID required", http.StatusBadRequest)
return
}

// Redirect to leader if necessary.
leader := h.store.leaderHTTP()
if leader != h.s.httpAddr {
Expand All @@ -322,25 +339,11 @@ func (h *handler) serveLease(w http.ResponseWriter, r *http.Request) {
scheme = "https://"
}

leader = scheme + leader + "/lease"
leader = scheme + leader + "/lease?" + q.Encode()
http.Redirect(w, r, leader, http.StatusTemporaryRedirect)
return
}

q := r.URL.Query()

// Get the requested lease name.
name := q.Get("name")
if name == "" {
http.Error(w, "lease name required", http.StatusBadRequest)
return
}
// Get the ID of the requesting node.
nodeIDStr := q.Get("nodeid")
if name == "" {
http.Error(w, "node ID required", http.StatusBadRequest)
return
}
// Convert node ID to an int.
nodeID, err := strconv.ParseUint(nodeIDStr, 10, 64)
if err != nil {
Expand Down

0 comments on commit f2c6a45

Please sign in to comment.