Skip to content

Commit

Permalink
fix(Dgraph): Forward task status requests to correct Alpha (#7774)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed May 5, 2021
1 parent 88ab633 commit 01f23d0
Show file tree
Hide file tree
Showing 9 changed files with 633 additions and 26,426 deletions.
4 changes: 2 additions & 2 deletions graphql/admin/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func resolveBackup(ctx context.Context, m schema.Mutation) (*resolve.Resolved, b
return resolve.EmptyResult(m, err), false
}

msg := fmt.Sprintf("Backup queued with ID %s", taskId)
msg := fmt.Sprintf("Backup queued with ID %#x", taskId)
data := response("Success", msg)
data["taskId"] = taskId
data["taskId"] = fmt.Sprintf("%#x", taskId)
return resolve.DataResult(
m,
map[string]interface{}{m.Name(): data},
Expand Down
4 changes: 2 additions & 2 deletions graphql/admin/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func resolveExport(ctx context.Context, m schema.Mutation) (*resolve.Resolved, b
return resolve.EmptyResult(m, err), false
}

msg := fmt.Sprintf("Export queued with ID %s", taskId)
msg := fmt.Sprintf("Export queued with ID %#x", taskId)
data := response("Success", msg)
data["taskId"] = taskId
data["taskId"] = fmt.Sprintf("%#x", taskId)
return resolve.DataResult(
m,
map[string]interface{}{m.Name(): data},
Expand Down
14 changes: 13 additions & 1 deletion graphql/admin/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,42 @@ import (
"context"
"encoding/json"
"fmt"
"strconv"
"time"

"github.com/dgraph-io/dgraph/graphql/resolve"
"github.com/dgraph-io/dgraph/graphql/schema"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/worker"
"github.com/pkg/errors"
)

type taskInput struct {
Id string
}

func resolveTask(ctx context.Context, q schema.Query) *resolve.Resolved {
// Get Task ID.
input, err := getTaskInput(q)
if err != nil {
return resolve.EmptyResult(q, err)
}
if input.Id == "" {
return resolve.EmptyResult(q, fmt.Errorf("task ID is missing"))
}
taskId, err := strconv.ParseUint(input.Id, 0, 64)
if err != nil {
err = errors.Wrapf(err, "invalid task ID: %s", input.Id)
return resolve.EmptyResult(q, err)
}

meta, err := worker.Tasks.Get(input.Id)
// Get TaskMeta from network.
req := &pb.TaskStatusRequest{TaskId: taskId}
resp, err := worker.TaskStatusOverNetwork(context.Background(), req)
if err != nil {
return resolve.EmptyResult(q, err)
}
meta := worker.TaskMeta(resp.GetTaskMeta())
return resolve.DataResult(
q,
map[string]interface{}{q.Name(): map[string]interface{}{
Expand Down
Loading

0 comments on commit 01f23d0

Please sign in to comment.