fn: slot hash id must be utf8 in gRPC (#1016)

This commit is contained in:
Tolga Ceylan
2018-05-29 16:26:43 -07:00
committed by GitHub
parent 47c6fb54af
commit 7f1d14d21f
2 changed files with 9 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"encoding/hex"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@@ -537,7 +538,12 @@ func (pr *pureRunner) handleTryCall(tc *runner.TryCall, state *callHandle) error
state.c = agent_call.(*call) state.c = agent_call.(*call)
if tc.SlotHashId != "" { if tc.SlotHashId != "" {
state.c.slotHashId = tc.SlotHashId hashId, err := hex.DecodeString(tc.SlotHashId)
if err != nil {
state.enqueueCallResponse(err)
return err
}
state.c.slotHashId = string(hashId[:])
} }
state.allocatedTime = strfmt.DateTime(time.Now()) state.allocatedTime = strfmt.DateTime(time.Now())
pr.spawnSubmit(state) pr.spawnSubmit(state)

View File

@@ -2,6 +2,7 @@ package agent
import ( import (
"context" "context"
"encoding/hex"
"encoding/json" "encoding/json"
"errors" "errors"
"io" "io"
@@ -126,7 +127,7 @@ func (r *gRPCRunner) TryExec(ctx context.Context, call pool.RunnerCall) (bool, e
// send explicit NACK // send explicit NACK
err = runnerConnection.Send(&pb.ClientMsg{Body: &pb.ClientMsg_Try{Try: &pb.TryCall{ err = runnerConnection.Send(&pb.ClientMsg{Body: &pb.ClientMsg_Try{Try: &pb.TryCall{
ModelsCallJson: string(modelJSON), ModelsCallJson: string(modelJSON),
SlotHashId: call.SlotHashId(), SlotHashId: hex.EncodeToString([]byte(call.SlotHashId())),
}}}) }}})
if err != nil { if err != nil {
logrus.WithError(err).Error("Failed to send message to runner node") logrus.WithError(err).Error("Failed to send message to runner node")