From 929f4b236119554f6f0c23ebdc38fbf5d91bfa72 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 9 Aug 2024 00:34:46 -0400 Subject: [PATCH] clean up --- cli/cli/commands/service/logs/logs.go | 7 ------- .../persistent_volume_logs_database_client.go | 3 +-- ...rsistent_volume_logs_database_client_test.go | 6 +++--- .../per_week_stream_logs_strategy.go | 9 +++------ .../server/engine_connect_server_service.go | 17 ----------------- 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/cli/cli/commands/service/logs/logs.go b/cli/cli/commands/service/logs/logs.go index 028039224c..550cb5df0b 100644 --- a/cli/cli/commands/service/logs/logs.go +++ b/cli/cli/commands/service/logs/logs.go @@ -27,7 +27,6 @@ import ( "os" "os/signal" "strconv" - "time" ) const ( @@ -263,16 +262,13 @@ func run( interruptChan := make(chan os.Signal, interruptChanBufferSize) signal.Notify(interruptChan, os.Interrupt) - var totalLogPrintDuration time.Duration for { select { case serviceLogsStreamContent, isChanOpen := <-serviceLogsStreamContentChan: if !isChanOpen { - logrus.Infof("CLI [logs.txt] TOTAL TIME TO PRINT LOGS: %v", totalLogPrintDuration) return nil } - startTime := time.Now() notFoundServiceUuids := serviceLogsStreamContent.GetNotFoundServiceUuids() for notFoundServiceUuid := range notFoundServiceUuids { @@ -291,11 +287,8 @@ func run( out.PrintOutLn(fmt.Sprintf("[%v] %v", colorPrinter(serviceIdentifier), serviceLog.GetContent())) } } - endTime := time.Now() - totalLogPrintDuration = endTime.Sub(startTime) case <-interruptChan: logrus.Debugf("Received signal interruption in service logs Kurtosis CLI command") - logrus.Infof("CLI [logs.go] TOTAL TIME TO PRINT LOGS: %v", totalLogPrintDuration) return nil } } diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go index d709f9fb28..6880e8db3e 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go @@ -13,8 +13,7 @@ import ( ) const ( - logLineBufferSize = 300 - oneSenderAdded = 1 + oneSenderAdded = 1 ) // persistentVolumeLogsDatabaseClient pulls logs from a Docker volume the engine is mounted to diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go index 4bcb3378ff..82f14c00e9 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go @@ -670,9 +670,9 @@ func TestStreamUserServiceLogsPerFileReturnsTimestampedLogLines(t *testing.T) { } } -// // ==================================================================================================== -// // -// // Private helper functions +// ==================================================================================================== +// +// Private helper functions // // ==================================================================================================== func executeStreamCallAndGetReceivedServiceLogLines( diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/stream_logs_strategy/per_week_stream_logs_strategy.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/stream_logs_strategy/per_week_stream_logs_strategy.go index 753776cdfa..fc6533c5a3 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/stream_logs_strategy/per_week_stream_logs_strategy.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/stream_logs_strategy/per_week_stream_logs_strategy.go @@ -197,8 +197,7 @@ func (strategy *PerWeekStreamLogsStrategy) streamAllLogs( return stacktrace.Propagate(err, "An error occurred converting the json log string '%v' into json.", jsonLogStr) } - err = strategy.sendJsonLogLine(jsonLog, conjunctiveLogLinesFiltersWithRegex, logLineSender, serviceUuid) - if err != nil { + if err = strategy.sendJsonLogLine(jsonLog, conjunctiveLogLinesFiltersWithRegex, logLineSender, serviceUuid); err != nil { return err } } @@ -258,8 +257,7 @@ func (strategy *PerWeekStreamLogsStrategy) streamTailLogs( if err != nil { return stacktrace.Propagate(err, "An error occurred converting the json log string '%v' into json.", jsonLogStr) } - err = strategy.sendJsonLogLine(jsonLog, conjunctiveLogLinesFiltersWithRegex, logLineSender, serviceUuid) - if err != nil { + if err = strategy.sendJsonLogLine(jsonLog, conjunctiveLogLinesFiltersWithRegex, logLineSender, serviceUuid); err != nil { return err } } @@ -394,8 +392,7 @@ func (strategy *PerWeekStreamLogsStrategy) followLogs( // if tail package fails to parse a valid new line, fail fast return stacktrace.NewError("hpcloud/tail returned the following line: '%v' that was not valid json.\nThis is potentially a bug in tailing package.", logLine.Text) } - err = strategy.sendJsonLogLine(jsonLog, conjunctiveLogLinesFiltersWithRegex, logLineSender, serviceUuid) - if err != nil { + if err = strategy.sendJsonLogLine(jsonLog, conjunctiveLogLinesFiltersWithRegex, logLineSender, serviceUuid); err != nil { return stacktrace.Propagate(err, "An error occurred sending json log line '%v'.", logLine.Text) } } diff --git a/engine/server/engine/server/engine_connect_server_service.go b/engine/server/engine/server/engine_connect_server_service.go index a3f3c84225..3fc908e916 100644 --- a/engine/server/engine/server/engine_connect_server_service.go +++ b/engine/server/engine/server/engine_connect_server_service.go @@ -347,8 +347,6 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c } }() - var totalLogStreamDuration time.Duration - var counter int for { select { //stream case @@ -356,39 +354,24 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c //If the channel is closed means that the logs database client won't continue sending streams if !isChanOpen { logrus.Debug("Exiting the stream loop after receiving a close signal from the service logs by service UUID channel") - logrus.Infof("ENGINE [engine_connect_server_service.go] TOTAL TIME TO STREAM LOGS IN ENGINE: %v", totalLogStreamDuration) return nil } - // print out num log lines every 100 lines times - //for serviceUUID, logs := range serviceLogsByServiceUuid { - // if counter%100 == 0 { - // logrus.Infof("NUM LOG LINES FOR SERVICE '%v' CHECK IN ENGINE CONNECT SERVICE: %v", serviceUUID, len(logs)) - // } - //} - - startTime := time.Now() getServiceLogsResponse := newLogsResponse(requestedServiceUuids, serviceLogsByServiceUuid, notFoundServiceUuids) if err := stream.Send(getServiceLogsResponse); err != nil { return stacktrace.Propagate(err, "An error occurred sending the stream logs for service logs response '%+v'", getServiceLogsResponse) } - counter += 1 - endTime := time.Now() - totalLogStreamDuration += endTime.Sub(startTime) //client cancel ctx case case <-contextWithCancel.Done(): logrus.Debug("The user service logs stream has done") - logrus.Infof("ENGINE [engine_connect_server_service.go] TOTAL TIME TO STREAM LOGS IN ENGINE: %v", totalLogStreamDuration) return nil //error from logs database case case err, isChanOpen := <-errChan: if isChanOpen { logrus.Debug("Exiting the stream because an error from the logs database client was received through the error chan.") - logrus.Infof("ENGINE [engine_connect_server_service.go] TOTAL TIME TO STREAM LOGS IN ENGINE: %v", totalLogStreamDuration) return stacktrace.Propagate(err, "An error occurred streaming user service logs.") } logrus.Debug("Exiting the stream loop after receiving a close signal from the error chan") - logrus.Infof("ENGINE [engine_connect_server_service.go] TOTAL TIME TO STREAM LOGS IN ENGINE: %v", totalLogStreamDuration) return nil } }