project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Bug] Snapshot timestamps differ between the VM view and the cluster overview

Open MrMasterbay opened this issue 2 months ago • 2 comments

Describe the bug

The same snapshot shows a different time depending on which view you open. The cluster-wide snapshot overview renders it in UTC, the per-VM snapshot list renders it in the browser timezone. In CEST that is a two-hour difference on the same snapshot.

Reported by an operator, who correctly suspected timezones.

Steps to Reproduce

  1. Create a snapshot on any VM.
  2. Open the VM, go to its snapshot list, note the timestamp.
  3. Go to the cluster-wide snapshot overview and find the same snapshot.
  4. The two timestamps differ by the UTC offset of the browser.

Expected behavior

Both views show the same local time, and both respect the 12h/24h preference like the rest of the UI.

Environment

  • PegaProx Version: 1.2.0
  • Installation Method: Docker
  • OS: Debian 13
  • Browser: Chrome latest
  • Behind Reverse Proxy? No
  • UI? Corporate

Logs

n/a - display only

Screenshots

n/a

Checklist

  • [x] I have searched existing issues to make sure this is not a duplicate
  • [x] I am using the latest version of PegaProx
  • [x] I have put enough in here that someone can start on it without asking me three questions first
  • [x] I understand PegaProx is maintained by volunteers in their free time

Cause, since I had a look already:

  • pegaprox/api/vms.py, /api/snapshots/overview formats server-side in UTC: datetime.fromtimestamp(snap_ts, tz=timezone.utc) then strftime("%Y-%m-%d %H:%M"), and web/src/dashboard.js prints that string verbatim.
  • web/src/vm_config.js and web/src/vm_modals.js do new Date(snap.snaptime * 1000).toLocaleString(), i.e. browser-local, and bypass the shared fmtDate() so they also ignore the 12h/24h setting.

Suggested fix: return the raw epoch from the overview next to the existing field and render both places through fmtDate().

MrMasterbay avatar Sep 21 '26 11:09 MrMasterbay

Fixed on Testing (152b782 + 6ffbf65).

Went with your suggestion — the overview hands over the raw epoch now and all three places render through fmtDate(), which already handles epoch seconds and already respects the 12h/24h setting. That also picks up the second half of the report: the two per-VM lists were bypassing fmtDate entirely, so they ignored that preference as well.

Kept snapshot_date in the payload. The overview table sorts on it, and an older frontend hitting a newer backend shouldn't break. There's a test pinning that the string and the epoch stay in agreement so they can't quietly drift.

The cluster dialog also picked up the SSH toggle from #941 in the same build.

Marcus

mkellermann97 avatar Sep 22 '26 09:09 mkellermann97

The cluster snapshot overview now gets the raw snapshot time and shows it in the browser's local time, like the per-VM snapshot lists, so both views show the same time. All three places use the shared date formatter and follow the 12h/24h setting. This ships in 1.3.0.

Marcus

mkellermann97 avatar Oct 07 '26 04:10 mkellermann97