-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: aryans1204 <[email protected]> Add VHIVE_REPO and LOADER_REPO to setup script config Signed-off-by: Mohsen Ghasemi <[email protected]> Added tests and created new vSwarm invoker Fixed linting Fixed VSwarm Invoker for Knative mode Committer: aryans1204 [email protected] Fixed VSwarm Invoker for Knative mode Added new invoker for vSwarm functions and added tests Signed-off-by: aryans1204 <[email protected]> Fixed formatting under grpc_client.go Signed-off-by: aryans1204 <[email protected]> Fixed driver tests Signed-off-by: aryans1204 <[email protected]> Fixed linting and slimmed VSwarm tests Signed-off-by: aryans1204 <[email protected]>
- Loading branch information
1 parent
c9ee3d7
commit c447b94
Showing
10 changed files
with
282 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ jobs: | |
[ | ||
config, | ||
driver, | ||
driver/clients, | ||
generator, | ||
trace, | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package clients | ||
|
||
import ( | ||
"github.com/vhive-serverless/loader/pkg/config" | ||
"github.com/vhive-serverless/loader/pkg/common" | ||
proto "github.com/vhive-serverless/vSwarm/utils/protobuf/helloworld" | ||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" | ||
mc "github.com/vhive-serverless/loader/pkg/metric" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
"github.com/sirupsen/logrus" | ||
"strings" | ||
"time" | ||
"github.com/google/uuid" | ||
"context" | ||
) | ||
|
||
type grpcVSwarmInvoker struct { | ||
cfg *config.LoaderConfiguration | ||
} | ||
|
||
func newGRPCVSwarmInvoker(cfg *config.LoaderConfiguration) *grpcVSwarmInvoker { | ||
return &grpcVSwarmInvoker{ | ||
cfg: cfg, | ||
} | ||
} | ||
|
||
func (i *grpcVSwarmInvoker) Invoke(function *common.Function, runtimeSpec *common.RuntimeSpecification) (bool, *mc.ExecutionRecord) { | ||
logrus.Tracef("(Invoke)\t %s: %d[ms], %d[MiB]", function.Name, runtimeSpec.Runtime, runtimeSpec.Memory) | ||
|
||
record := &mc.ExecutionRecord{ | ||
ExecutionRecordBase: mc.ExecutionRecordBase{ | ||
RequestedDuration: uint32(runtimeSpec.Runtime * 1e3), | ||
}, | ||
} | ||
|
||
//////////////////////////////////// | ||
// INVOKE FUNCTION | ||
//////////////////////////////////// | ||
start := time.Now() | ||
record.StartTime = start.UnixMicro() | ||
|
||
var dialOptions []grpc.DialOption | ||
dialOptions = append(dialOptions, grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if i.cfg.EnableZipkinTracing { | ||
dialOptions = append(dialOptions, grpc.WithStatsHandler(otelgrpc.NewClientHandler())) | ||
} | ||
|
||
grpcStart := time.Now() | ||
|
||
conn, err := grpc.NewClient(function.Endpoint, dialOptions...) | ||
if err != nil { | ||
logrus.Debugf("Failed to establish a gRPC connection - %v\n", err) | ||
|
||
record.ResponseTime = time.Since(start).Microseconds() | ||
record.ConnectionTimeout = true | ||
|
||
return false, record | ||
} | ||
defer gRPCConnectionClose(conn) | ||
|
||
record.GRPCConnectionEstablishTime = time.Since(grpcStart).Microseconds() | ||
|
||
executionCxt, cancelExecution := context.WithTimeout(context.Background(), time.Duration(i.cfg.GRPCFunctionTimeoutSeconds)*time.Second) | ||
|
||
defer cancelExecution() | ||
|
||
grpcClient := proto.NewGreeterClient(conn) | ||
response, err := grpcClient.SayHello(executionCxt, &proto.HelloRequest{ | ||
Name: "Invoke Relay", | ||
VHiveMetadata: MakeVHiveMetadata( | ||
uuid.New().String(), | ||
uuid.New().String(), | ||
time.Now().UTC(), | ||
), | ||
}) | ||
if err != nil { | ||
logrus.Debugf("gRPC timeout exceeded for function %s - %s", function.Name, err) | ||
|
||
record.ResponseTime = time.Since(start).Microseconds() | ||
record.FunctionTimeout = true | ||
|
||
return false, record | ||
} | ||
record.ResponseTime = time.Since(start).Microseconds() | ||
record.ActualDuration = uint32(record.ResponseTime) | ||
record.Instance = extractInstanceName(response.GetMessage()) | ||
if strings.HasPrefix(response.GetMessage(), "FAILURE - mem_alloc") { | ||
record.MemoryAllocationTimeout = true | ||
} else { | ||
record.ActualMemoryUsage = common.Kib2Mib(0) | ||
} | ||
|
||
logrus.Tracef("(E2E Latency) %s: %.2f[ms]\n", function.Name, float64(record.ResponseTime)/1e3) | ||
|
||
return true, record | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.