-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NOISSUE - Handle larger manifests exceeding the default grpc limit #161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add tests
manager/api/grpc/server.go
Outdated
return err | ||
} | ||
for start := 0; start < len(data); start += chunkSize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a byte buffer to read chunks, see cocos sdk for an example
2c6374f
to
46e469e
Compare
manager/manager_test.go
Outdated
) | ||
|
||
func init() { | ||
logger, err := mglog.New(os.Stdout, "debug") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use mock logger for tests
manager/manager_test.go
Outdated
func (s *svc) Run(ipAddress string, runReqChan chan *manager.ServerStreamMessage, authInfo credentials.AuthInfo) { | ||
privKey, err := rsa.GenerateKey(rand.Reader, keyBitSize) | ||
if err != nil { | ||
s.logger.Error(fmt.Sprintf("Error generating public key: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail test rather than logging errors, pass testting.T on svc struct
manager/manager_test.go
Outdated
attestedTLS = false | ||
) | ||
|
||
func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use testmain for setup rather than init for test setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test cases for different senarios
@smithjilks please resolve these remarks |
93e1e2b
to
546e2b4
Compare
manager/api/grpc/client.go
Outdated
@@ -32,21 +37,37 @@ func (client ManagerClient) Process(ctx context.Context, cancel context.CancelFu | |||
eg, ctx := errgroup.WithContext(ctx) | |||
|
|||
eg.Go(func() error { | |||
var data bytes.Buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name appropriately
Signed-off-by: Jilks Smith <[email protected]>
Signed-off-by: Jilks Smith <[email protected]>
manager/api/grpc/client.go
Outdated
if len(mes.RunReqChunks.Data) == 0 { | ||
var runReq pkgmanager.ComputationRunReq | ||
if err = proto.Unmarshal(runReqBuffer.Bytes(), &runReq); err != nil { | ||
return errCorruptedManifest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap the error
manager/api/grpc/client.go
Outdated
} | ||
runReqBuffer.Write(mes.RunReqChunks.Data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle error
manager/api/grpc/server.go
Outdated
case *manager.ServerStreamMessage_RunReq: | ||
data, err := proto.Marshal(msg.RunReq) | ||
if err != nil { | ||
return err | ||
} | ||
dataBuffer := bytes.NewBuffer(data) | ||
buf := make([]byte, bufferSize) | ||
for { | ||
n, err := dataBuffer.Read(buf) | ||
chunk := &manager.ServerStreamMessage{ | ||
Message: &manager.ServerStreamMessage_RunReqChunks{ | ||
RunReqChunks: &manager.RunReqChunks{ | ||
Data: buf[:n], | ||
}, | ||
}, | ||
} | ||
|
||
if err := stream.Send(chunk); err != nil { | ||
return err | ||
} | ||
|
||
if err == io.EOF { | ||
break | ||
} | ||
} | ||
|
||
case *manager.ServerStreamMessage_TerminateReq: | ||
terminate := &manager.ServerStreamMessage{ | ||
Message: &manager.ServerStreamMessage_TerminateReq{ | ||
TerminateReq: msg.TerminateReq, | ||
}, | ||
} | ||
if err := stream.Send(terminate); err != nil { | ||
return err | ||
} | ||
|
||
default: | ||
return ErrUnexpectedMsg | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle all message types as in main
manager/api/grpc/server.go
Outdated
case *manager.ServerStreamMessage_TerminateReq: | ||
terminate := &manager.ServerStreamMessage{ | ||
Message: &manager.ServerStreamMessage_TerminateReq{ | ||
TerminateReq: msg.TerminateReq, | ||
}, | ||
} | ||
if err := stream.Send(terminate); err != nil { | ||
return err | ||
} | ||
|
||
case *manager.ServerStreamMessage_StopComputation: | ||
stopComp := &manager.ServerStreamMessage{ | ||
Message: &manager.ServerStreamMessage_StopComputation{ | ||
StopComputation: msg.StopComputation, | ||
}, | ||
} | ||
if err := stream.Send(stopComp); err != nil { | ||
return err | ||
} | ||
|
||
case *manager.ServerStreamMessage_BackendInfoReq: | ||
backendInfo := &manager.ServerStreamMessage{ | ||
Message: &manager.ServerStreamMessage_BackendInfoReq{ | ||
BackendInfoReq: msg.BackendInfoReq, | ||
}, | ||
} | ||
if err := stream.Send(backendInfo); err != nil { | ||
return err | ||
} | ||
default: | ||
return ErrUnexpectedMsg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the fault case to send all other messages, and no need to create new variables.
manager/api/grpc/client.go
Outdated
if err := client.stream.Send(&pkgmanager.ClientStreamMessage{Message: runRes}); err != nil { | ||
return err | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil |
is a goroutine on client and should not return here
What type of PR is this?
This is a feature to allow streaming manifests larger than the default grpc limit
What does this do?
Adds ability to stream large computation manifests in chunks.
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
No, I have not included tests.
Did you document any new/modified feature?
Notes