Skip to content

Commit

Permalink
feat: improved log experience on the UI. (#1368)
Browse files Browse the repository at this point in the history
This PR:
I have the logging experience now, where users can see large amount of
logs. It behaves like terminal where if at bottom it automatically
tracks the new logs, otherwise stays in place until user goes to bottom.

I have included copy and download functionality as well, where users can
do that for service logs and logs generated during enclave creation.
  • Loading branch information
Peeeekay committed Sep 25, 2023
1 parent 3fe50d2 commit 760c7f0
Show file tree
Hide file tree
Showing 32 changed files with 10,819 additions and 4,525 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 14 additions & 30 deletions enclave-manager/server/server.go
Expand Up @@ -227,26 +227,22 @@ func (c *WebServer) RunStarlarkPackage(ctx context.Context, req *connect.Request
Msg: req.Msg.RunStarlarkPackageArgs,
}

apicStream, err := (*apiContainerServiceClient).RunStarlarkPackage(ctx, serviceRequest)
ctxWithCancel, cancel := context.WithCancel(ctx)
logs := getRuntimeLogsWhenCreatingEnclave(cancel, apicStream)
for {
select {
case <-ctxWithCancel.Done():
err := apicStream.Close()
close(logs)
if err != nil {
return stacktrace.Propagate(err, "Error occurred after closing the stream")
}
return nil
case resp := <-logs:
errWhileSending := str.Send(resp)
if errWhileSending != nil {
logrus.Errorf("error occurred: %+v", errWhileSending)
return stacktrace.Propagate(errWhileSending, "Error occurred while sending streams")
}
apiClient, 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")
}
}

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")
}
return nil
}

func (c *WebServer) DestroyEnclave(ctx context.Context, req *connect.Request[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs]) (*connect.Response[emptypb.Empty], error) {
Expand Down Expand Up @@ -437,15 +433,3 @@ func RunEnclaveManagerApiServer(enforceAuth bool) error {
}
return nil
}

func getRuntimeLogsWhenCreatingEnclave(cancel context.CancelFunc, client *connect.ServerStreamForClient[kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine]) chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine {
result := make(chan *kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)
go func() {
for client.Receive() {
res := client.Msg()
result <- res
}
cancel()
}()
return result
}

0 comments on commit 760c7f0

Please sign in to comment.