fix(model): clear SinceTime when switching log time windows#3980
Open
SebTardif wants to merge 1 commit into
Open
fix(model): clear SinceTime when switching log time windows#3980SebTardif wants to merge 1 commit into
SebTardif wants to merge 1 commit into
Conversation
When a user switches between time-based views (pressing 0-6 for tail/head/1m/5m/etc), the stale SinceTime from the previous stream was preserved in LogOptions. Although ToPodLogOptions correctly prioritizes SinceSeconds over SinceTime, the lingering timestamp could cause issues on stream reconnection when SinceSeconds is reset to 0 (default) — the API would resume from the stale timestamp instead of showing the full tail. Clear SinceTime in both SetSinceSeconds and Head to ensure clean state when the user explicitly changes the time window. This prevents log streams from silently resuming at an unexpected point after a reconnect or mode switch. Add tests verifying that SetSinceSeconds and Head both clear SinceTime. Ref derailed#3051 — part of broader log viewer reliability improvements Ref derailed#1846 — logs missing or appearing at wrong offset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a user switches between time-based log views (pressing
0–6for tail/head/1m/5m/etc), the staleSinceTimefrom the previous stream was preserved inLogOptions. This could cause the log stream to silently resume from an unexpected timestamp instead of showing the correct time window.Changes
Model fix (
internal/model/log.go)SetSinceSeconds(): clearSinceTimebefore restarting the streamHead(): clearSinceTimebefore restarting the streamTests (
internal/model/log_test.go)TestLogSetSinceSecondsClearsSinceTime— verifiesSetSinceSecondsclears the stale timestampTestLogHeadClearsSinceTime— verifiesHeadclears the stale timestampRoot Cause
Every log line appended via
model.Log.Append()updateslogOptions.SinceTimeto the line's timestamp (used for stream resume on reconnect). When the user switches time windows,SetSinceSecondsandHeadcorrectly set their respective fields but never clearedSinceTime. WhileToPodLogOptions()prioritizesSinceSeconds > 0overSinceTime, edge cases during reconnection whenSinceSecondsresets to 0 could cause the API to resume from the stale timestamp.References