Skip to content

Commit

Permalink
Warn client when invocation fail.
Browse files Browse the repository at this point in the history
Before the relay panics when the function
not repond in time or something breaks.
Instead of breaking we send back a waring to
the invoking client.

Signed-off-by: David Schall <[email protected]>
  • Loading branch information
dhschall authored and shyamjesal committed Feb 9, 2024
1 parent c5ae2f2 commit 54daf7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tools/relay/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/vhive-serverless/vSwarm/utils/tracing/go => ../../utils/traci

require (
github.com/sirupsen/logrus v1.9.3
github.com/vhive-serverless/vSwarm-proto v0.4.3-0.20231030051952-95c2986277cc
github.com/vhive-serverless/vSwarm-proto v0.5.0
github.com/vhive-serverless/vSwarm/utils/tracing/go v0.0.0-20230802102142-dbfda39fc27c
google.golang.org/grpc v1.60.1
)
Expand Down
4 changes: 2 additions & 2 deletions tools/relay/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/vhive-serverless/vSwarm-proto v0.4.3-0.20231030051952-95c2986277cc h1:jzG4kdqtKGvAIuIvAa1aBGsbceeDEfL/w0wn7E0gO6E=
github.com/vhive-serverless/vSwarm-proto v0.4.3-0.20231030051952-95c2986277cc/go.mod h1:SwR0sLup2AAxyjm81H8OPr+jd2D7gNBZSMTGJZaedWw=
github.com/vhive-serverless/vSwarm-proto v0.5.0 h1:EWPD0xTs1XkBerTQVsQ9sFJSOyCUKOu7Y3L9AftuLow=
github.com/vhive-serverless/vSwarm-proto v0.5.0/go.mod h1:bUm7QUFkBnFNVhbG7PHWRNT5tXRFXR9WEkfIGE82o+0=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE=
go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc=
Expand Down
20 changes: 12 additions & 8 deletions tools/relay/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,24 @@ var (
generatorString = flag.String("generator", "unique", "Generator type (unique / linear / random)")
value = flag.String("value", "helloWorld", "String input to pass to benchmark")
functionMethod = flag.String("function-method", "default", "Which method of benchmark to invoke")
verbose = flag.Bool("verbose", false, "Enable verbose log printing")

// Client
grpcClient grpcClients.GrpcClient
inputGenerator grpcClients.Generator
)

func isDebuggingEnabled() bool {
debugging := false
if val, ok := os.LookupEnv("ENABLE_DEBUGGING"); !ok || val == "false" {
return false
debugging = false
} else if val == "true" {
return true
debugging = true
} else {
log.Fatalf("ENABLE_DEBUGGING has unexpected value: `%s`", val)
return false
}
return debugging || *verbose
}

func main() {
Expand All @@ -99,7 +102,9 @@ func main() {
serviceName := grpcClients.FindServiceName(*functionName)
grpcClient = grpcClients.FindGrpcClient(serviceName)
ctx := context.Background()
grpcClient.Init(ctx, *functionEndpointURL, *functionEndpointPort)
if err := grpcClient.Init(ctx, *functionEndpointURL, *functionEndpointPort); err != nil {
log.Fatalf("Fail to init client: %s", err)
}
defer grpcClient.Close()

// Configure the Input generator
Expand Down Expand Up @@ -146,13 +151,12 @@ func main() {
}

func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
log.Info("Received from invoker: ", in.GetName())

// Create new packet
pkt := inputGenerator.Next()
log.Debug("Send to func: ", pkt)
reply := grpcClient.Request(ctx, pkt)
log.Debug("Recv from func: ", reply)
log.Debugf("Send to func: %s\n", pkt)
reply, err := grpcClient.Request(ctx, pkt)
log.Debugf("Recv from func: %s\n", reply)

return &pb.HelloReply{Message: reply}, nil
return &pb.HelloReply{Message: reply}, err
}

0 comments on commit 54daf7e

Please sign in to comment.