Skip to content

Commit

Permalink
fix(moveTablet): make move tablet namespace aware (#7468)
Browse files Browse the repository at this point in the history
This makes moveTablet namespace aware.
User needs to pass namespace as a query parameter, else default namespace is assumed.
  • Loading branch information
NamanJain8 authored Feb 22, 2021
1 parent 03e7a1d commit 5ea26a0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions dgraph/cmd/zero/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/http"
"strconv"
"strings"
"time"

"github.com/dgraph-io/dgraph/protos/pb"
Expand Down Expand Up @@ -155,8 +156,19 @@ func (st *state) moveTablet(w http.ResponseWriter, r *http.Request) {

tablet := r.URL.Query().Get("tablet")

// TODO(Ahsan): The move tablet request should be namespace aware.
tablet = x.NamespaceAttr(x.GalaxyNamespace, tablet)
namespace := r.URL.Query().Get("namespace")
namespace = strings.TrimSpace(namespace)
ns := x.GalaxyNamespace
if namespace != "" {
var err error
if ns, err = strconv.ParseUint(namespace, 0, 64); err != nil {
w.WriteHeader(http.StatusBadRequest)
x.SetStatus(w, x.ErrorInvalidRequest, "Invalid namespace in query parameter.")
return
}
}

tablet = x.NamespaceAttr(ns, tablet)
if len(tablet) == 0 {
w.WriteHeader(http.StatusBadRequest)
x.SetStatus(w, x.ErrorInvalidRequest, "tablet is a mandatory query parameter")
Expand Down

0 comments on commit 5ea26a0

Please sign in to comment.