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: tail logs from end of log file #1339

Merged
merged 5 commits into from Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -119,7 +119,7 @@ func (strategy *PerWeekStreamLogsStrategy) StreamLogs(
isLastLogLine = true
} else {
if shouldFollowLogs {
if err = strategy.tailLogs(latestLogFile, logsByKurtosisUserServiceUuidChan, serviceUuid, conjunctiveLogLinesFiltersWithRegex); err != nil {
if err = strategy.followLogs(latestLogFile, logsByKurtosisUserServiceUuidChan, serviceUuid, conjunctiveLogLinesFiltersWithRegex); err != nil {
streamErrChan <- stacktrace.Propagate(err, "An error occurred following logs for service '%v' in enclave '%v'.", serviceUuid, enclaveUuid)
return
}
Expand All @@ -142,7 +142,7 @@ func (strategy *PerWeekStreamLogsStrategy) StreamLogs(

if isLastLogLine {
if shouldFollowLogs {
if err = strategy.tailLogs(latestLogFile, logsByKurtosisUserServiceUuidChan, serviceUuid, conjunctiveLogLinesFiltersWithRegex); err != nil {
if err = strategy.followLogs(latestLogFile, logsByKurtosisUserServiceUuidChan, serviceUuid, conjunctiveLogLinesFiltersWithRegex); err != nil {
streamErrChan <- stacktrace.Propagate(err, "An error occurred following logs for service '%v' in enclave '%v'.", serviceUuid, enclaveUuid)
return
}
Expand Down Expand Up @@ -199,14 +199,17 @@ func (strategy *PerWeekStreamLogsStrategy) getRetainedLogsFilePaths(filesystem v
}

// tail -f [filepath]
func (strategy *PerWeekStreamLogsStrategy) tailLogs(
func (strategy *PerWeekStreamLogsStrategy) followLogs(
filepath string,
logsByKurtosisUserServiceUuidChan chan map[service.ServiceUUID][]logline.LogLine,
serviceUuid service.ServiceUUID,
conjunctiveLogLinesFiltersWithRegex []logline.LogLineFilterWithRegex,
) error {
logTail, err := tail.TailFile(filepath, tail.Config{
Location: nil,
Location: &tail.SeekInfo{
Offset: 0,
Whence: io.SeekEnd, // start tailing from end of log file
},
ReOpen: false,
MustExist: true,
Poll: false,
Expand Down