Skip to content
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

fix: clean em api get service logs streaming logic #1589

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 19 additions & 34 deletions enclave-manager/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,20 @@ func (c *WebServer) GetServiceLogs(
req *connect.Request[kurtosis_engine_rpc_api_bindings.GetServiceLogsArgs],
str *connect.ServerStream[kurtosis_engine_rpc_api_bindings.GetServiceLogsResponse],
) error {
engineClient, err := (*c.engineServiceClient).GetServiceLogs(ctx, req)
serviceLogsStream, err := (*c.engineServiceClient).GetServiceLogs(ctx, req)
if err != nil {
return err
}

for engineClient.Receive() {
select {
case <-ctx.Done():
logrus.Debug("Closing the engine client after receiving abort signal from the client")
err := engineClient.Close()
if err != nil {
logrus.Errorf("Error ocurred: %+v", err)
return err
}
return nil
default:
resp := engineClient.Msg()
errWhileSending := str.Send(resp)
if errWhileSending != nil {
return errWhileSending
}
for serviceLogsStream.Receive() {
resp := serviceLogsStream.Msg()
errWhileSending := str.Send(resp)
if errWhileSending != nil {
return stacktrace.Propagate(errWhileSending, "An error occurred in the enclave manager server attempting to send services logs.")
}
}
if engineClient.Err() != nil {
return engineClient.Err()
if serviceLogsStream.Err() != nil {
return stacktrace.Propagate(serviceLogsStream.Err(), "An error occurred in the enclave manager server attempting to receive services logs.")
}

return nil
Expand Down Expand Up @@ -216,31 +205,28 @@ func (c *WebServer) ListFilesArtifactNamesAndUuids(ctx context.Context, req *con
func (c *WebServer) RunStarlarkPackage(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.RunStarlarkPackageRequest], str *connect.ServerStream[kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine]) error {
apiContainerServiceClient, err := c.createAPICClient(req.Msg.ApicIpAddress, req.Msg.ApicPort)
runPackageArgs := req.Msg.RunStarlarkPackageArgs
boolean := true
runPackageArgs.ClonePackage = &boolean

shouldClonePackage := true
runPackageArgs.ClonePackage = &shouldClonePackage
if err != nil {
return stacktrace.Propagate(err, "Failed to create the APIC client")
}
serviceRequest := &connect.Request[kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs]{
Msg: req.Msg.RunStarlarkPackageArgs,
}

apiClient, err := (*apiContainerServiceClient).RunStarlarkPackage(ctx, serviceRequest)
starlarkLogsStream, err := (*apiContainerServiceClient).RunStarlarkPackage(ctx, serviceRequest)

for apiClient.Receive() {
resp := apiClient.Msg()
errWhileSending := str.Send(resp)
if errWhileSending != nil {
logrus.Errorf("Error occurred while sending stream frome enclave manager to the UI: %+v", errWhileSending)
return stacktrace.Propagate(errWhileSending, "Error occurred while sending streams")
for starlarkLogsStream.Receive() {
resp := starlarkLogsStream.Msg()
err = str.Send(resp)
if err != nil {
return stacktrace.Propagate(err, "An error occurred in the enclave manager server attempting to send run starlark package logs.")
}
}

if errWhileReceive := apiClient.Err(); errWhileReceive != nil {
logrus.Errorf("Error occurred while enclave manger is receiving streams from engine: %+v", errWhileReceive)
return stacktrace.Propagate(errWhileReceive, "Error occurred while receiving data from engine")
if err = starlarkLogsStream.Err(); err != nil {
return stacktrace.Propagate(err, "An error occurred in the enclave manager server attempting to receive run starlark package logs.")
}

return nil
}

Expand Down Expand Up @@ -277,7 +263,6 @@ func (c *WebServer) CreateEnclave(ctx context.Context, req *connect.Request[kurt
EnclaveInfo: result.Msg.EnclaveInfo,
},
}
logrus.Infof("Create Enclave: %+v", resp)
return resp, nil
}

Expand Down
1 change: 1 addition & 0 deletions engine/frontend/src/api/enclave.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const getServiceLogs = async (ctrl, enclaveName, serviceUuid, apiHost, fo
returnAllLogs: false,
numLogLines: numLogLines,
}
console.log("Sending GetServiceLogs Request with Args", args)
return enclaveManagerClient.getServiceLogs(args, {signal: ctrl.signal});
}

Expand Down
6 changes: 3 additions & 3 deletions engine/server/webapp/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "./static/css/main.2cce5778.css",
"main.js": "./static/js/main.8ed2cf3c.js",
"main.js": "./static/js/main.e15c6be0.js",
"index.html": "./index.html",
"main.2cce5778.css.map": "./static/css/main.2cce5778.css.map",
"main.8ed2cf3c.js.map": "./static/js/main.8ed2cf3c.js.map"
"main.e15c6be0.js.map": "./static/js/main.e15c6be0.js.map"
},
"entrypoints": [
"static/css/main.2cce5778.css",
"static/js/main.8ed2cf3c.js"
"static/js/main.e15c6be0.js"
]
}
2 changes: 1 addition & 1 deletion engine/server/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Kurtosis Enclave Manager</title><script defer="defer" src="./static/js/main.8ed2cf3c.js"></script><link href="./static/css/main.2cce5778.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Kurtosis Enclave Manager</title><script defer="defer" src="./static/js/main.e15c6be0.js"></script><link href="./static/css/main.2cce5778.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.