fix: monitor time-based search timezone offset#12275
Open
jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
Open
fix: monitor time-based search timezone offset#12275jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
Conversation
When searching monitor data by time range, the results were off by the server's timezone offset (e.g., 8 hours for UTC+8). The previous code used time.In(loc) which only changes the display timezone but doesn't adjust the actual moment in time for the DB query. The fix: when the frontend sends time in UTC but the server is in a different timezone, reconstruct the time.Time with the local timezone so the DB query matches the correct time range. This treats the frontend's time values as "wall clock time" in the server's timezone. Applied to both LoadMonitorData and LoadGPUMonitorData. Fixes 1Panel-dev#11891
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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
Fixes #11891 - Monitor time-based search is off by timezone offset (e.g., 8 hours for UTC+8 servers).
Root Cause
In
agent/app/service/monitor.go,LoadMonitorDataandLoadGPUMonitorDataused:time.In(loc)only changes the timezone label for display - it does NOT change the underlying moment in time. So the DB query still searched for the wrong time range.Fix
When the frontend sends time in UTC but the server runs in a different timezone, reconstruct the
time.Timewith the server's local timezone. This treats the time values as "wall clock time":This shifts the actual moment to match what the user selected in the UI.
Changed file
agent/app/service/monitor.go- Fix bothLoadMonitorDataandLoadGPUMonitorData