Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Aug 9, 2024
1 parent 5fe30ff commit 929f4b2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 35 deletions.
7 changes: 0 additions & 7 deletions cli/cli/commands/service/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"os"
"os/signal"
"strconv"
"time"
)

const (
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
)

const (
logLineBufferSize = 300
oneSenderAdded = 1
oneSenderAdded = 1
)

// persistentVolumeLogsDatabaseClient pulls logs from a Docker volume the engine is mounted to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,9 @@ func TestStreamUserServiceLogsPerFileReturnsTimestampedLogLines(t *testing.T) {
}
}

// // ====================================================================================================
// //
// // Private helper functions
// ====================================================================================================
//
// Private helper functions
//
// ====================================================================================================
func executeStreamCallAndGetReceivedServiceLogLines(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
17 changes: 0 additions & 17 deletions engine/server/engine/server/engine_connect_server_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,48 +347,31 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c
}
}()

var totalLogStreamDuration time.Duration
var counter int
for {
select {
//stream case
case serviceLogsByServiceUuid, isChanOpen := <-serviceLogsByServiceUuidChan:
//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
}
}
Expand Down

0 comments on commit 929f4b2

Please sign in to comment.