Agent status timing#81
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a client-server time synchronization issue affecting agent status display by moving agent status calculations entirely to the browser side. The change addresses cases where time delta between browser and server would incorrectly show agents as dead when the beacon window was smaller than the time difference.
Key changes:
- Refactored agent status logic to use server-provided timestamps and browser-side calculations
- Enhanced time parsing utilities to handle various timestamp formats consistently
- Improved agent lifecycle management with better pending kill state tracking
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/views/AgentsView.vue | Main view restructured to compute agent status client-side using server time and config |
| src/utils/agentUtil.js | Rewritten status calculation function to accept server time and config parameters |
| src/utils/utils.js | Enhanced time utilities with robust parsing and conversion functions |
| src/stores/agentStore.js | Added server time capture and pending kill state management |
| src/components/agents/DetailsModal.vue | Updated to use centralized status calculation with proper time handling |
| src/components/agents/AgentChartStatus.vue | Modified chart component to use consistent status calculation approach |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| : a | ||
| ); | ||
| // Flag agent as pending kill immediately | ||
| this.agents[idx]._pendingKill = true; |
There was a problem hiding this comment.
The agent is being flagged as pending kill twice - once through the map operation and once by direct assignment. The direct assignment on line 113 is redundant since the map operation already handles this.
| this.agents[idx]._pendingKill = true; |
There was a problem hiding this comment.
Is it though; I'm not sure during my testing that worked.
| const yesterday = givenMs >= Date.now() - day; | ||
| if (yesterday) { |
There was a problem hiding this comment.
The condition is incorrect - it should check if the given timestamp is within the last day, not if it's greater than or equal to yesterday's timestamp. This should be givenMs >= Date.now() - 2 * day.
| const yesterday = givenMs >= Date.now() - day; | |
| if (yesterday) { | |
| const now = new Date(); | |
| const yesterdayDate = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 1)); | |
| const isYesterday = | |
| d.getUTCFullYear() === yesterdayDate.getUTCFullYear() && | |
| d.getUTCMonth() === yesterdayDate.getUTCMonth() && | |
| d.getUTCDate() === yesterdayDate.getUTCDate(); | |
| if (isYesterday) { |
There was a problem hiding this comment.
shall we go with this suggestion then?
|
@deacon-mp |
|
Closing — PR #83 (merged) addressed the agent status timing issue by fetching status from the server directly, which supersedes this browser-side timing fix. |
Description
In certain instances the browser for access and the server running Caldera were on two machines thus creating a delta in time. In my testing it actually represented minutes and if the beacon window for an agent was less than that delta it would always show that agent as dead.
I rewrote the logic for the alive, dead, and pending kill to be solely calculated browser side.
This is purely ... I think a UI, user interaction bug fix and does not mess the actual functionality of the agent.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: