-
Notifications
You must be signed in to change notification settings - Fork 59
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
Remove temp file usage for logs #607
base: main
Are you sure you want to change the base?
Conversation
18085f3
to
ef34c69
Compare
ef34c69
to
a622abb
Compare
@@ -4328,6 +4328,9 @@ var tests = []testpair{ | |||
func TestAnalyzeLogLines(t *testing.T) { | |||
for _, pair := range tests { | |||
l, s := logs.AnalyzeLogLines(pair.logLinesIn) | |||
for idx := range l { | |||
l[idx].Content = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple tests now do this to avoid needing to copy-paste the log content into the expected output struct. I could do that if desired, it would just be tedious.
fmt.Printf("%s\n", logFileContents[logLine.ByteStart:logLine.ByteEnd]) | ||
fmt.Printf(" Level: %s\n", logLine.LogLevel) | ||
fmt.Printf(" Content: %#v\n", logFileContents[logLine.ByteContentStart:logLine.ByteEnd]) | ||
fmt.Printf(" %s: %s", logLine.LogLevel, logLine.Content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried running the debug command yet. Someone might have a preference on the output format.
One downside to this PR is we can no longer debug the entire log content including the unparsed log prefix.
@@ -332,24 +329,16 @@ func postprocessAndSendLogs(ctx context.Context, server *state.Server, globalCol | |||
|
|||
for idx := range transientLogState.LogFiles { | |||
logFile := &transientLogState.LogFiles[idx] | |||
logFile.ByteSize = int64(logFile.LogLines[len(logFile.LogLines)-1].ByteEnd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we no longer have the original string at this point in the code, looking at the last log line's ByteEnd
is the only way to know the file size. Maybe this should be moved to an earlier processing stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and in terms of this code's soundness, I vaguely remember that on production we do receive log files that don't contain any log lines, so this would panic. Should we really be submitting empty snapshots?
Followup to #597, this removes temp file usage in log code paths, instead keeping the log content in memory.