Agent device cache #273

Closed
opened 2026-03-28 04:22:58 +00:00 by mfreeman451 · 0 comments
Owner

Imported from GitHub.

Original GitHub issue: #769
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/769
Original created: 2025-05-12T17:22:45Z


Enhancement: Implement Device Information Collection in ServiceRadar Agent

Overview

This issue tracks the implementation of device information collection in the serviceradar-agent as outlined in the [[ServiceRadar Agent Device Caching & Reporting PRD](https://github.com/carverauto/serviceradar/tree/main/sr-architecture-and-design/prd)](https://github.com/carverauto/serviceradar/tree/main/sr-architecture-and-design/prd). The agent will continue collecting raw DeviceInfo from edge services (sweep, ICMP, port, SNMP) without local caching, include AgentID in responses, and rely on the core service to derive the devices stream using a Proton materialized view. Pollers will attach PollerID to status messages, ensuring traceability.

Description

The current agent collects raw data but lacks agent_id and poller_id tracking, and a previous plan for a local DeviceCache raised memory footprint concerns. This implementation will:

  • Preserve existing raw data collection, adding only agent_id to StatusResponse.
  • Use existing config fields for AgentID and PollerID instead of context propagation.
  • Enable pollers to attach PollerID to service status messages.
  • Resolve the OpenPorts reference issue in the sweep service.
  • Minimize agent memory usage by removing all device caching code.

The core service will derive the devices stream using a materialized view, aggregating and deduplicating raw data from sweep_results, icmp_results, and snmp_results streams.

Implementation Tasks

Phase 1: Core Infrastructure (Est: 3 days)

  • Update data structures in pkg/agent/types.go
    • Remove DeviceCache, DeviceState, and DeviceCacheConfig.
    • Ensure ServerConfig includes AgentID.
  • Update Protocol Buffers in proto/serviceradar.proto
    • Add agent_id field to StatusResponse.
    • Add agent_id and poller_id fields to ServiceStatus.
    • Remove DeviceStatusRequest, DeviceStatusResponse, and devices from PollerStatusRequest.
  • Generate updated gRPC code from proto definitions.

Phase 2: Agent and Poller Updates (Est: 4 days)

  • Update Agent
    • Remove pkg/agent/devices.go (entire file).
    • Update GetStatus() in pkg/agent/server.go to add AgentID from config to StatusResponse.
    • Update edge service response handling to ensure proper raw data collection.
    • Remove device cache initialization, maintenance, and extraction functions.
  • Update Poller
    • Update ServiceCheck.execute() in pkg/poller/poller.go to preserve AgentID from agent responses.
    • Update reportToCore() to add PollerID to each ServiceStatus before reporting.
    • Remove device-specific handling from poller methods.

Phase 3: Testing (Est: 4 days)

  • Unit Tests
    • Test GetStatus for AgentID inclusion in StatusResponse.
    • Test ServiceCheck.execute() for preserving AgentID.
    • Test reportToCore() for adding PollerID.
  • Integration Tests
    • Test agent-poller communication with agent_id and poller_id.
    • Verify raw data consistency with existing collection.
  • System Tests
    • End-to-end test from edge services to core with agent_id and poller_id.
    • Performance test with 10,000+ devices, monitoring agent memory.

Notes

  • Updated approach uses existing config fields for AgentID and PollerID rather than context propagation.
  • Preserves existing data flow and raw data collection without modification.
  • Focuses on identity propagation through the pipeline without changing core functionality.
  • Removes all device caching code to minimize memory footprint.
  • Relies on core service materialized view for device derivation.

Acceptance Criteria

  1. Agent includes agent_id in all StatusResponse messages.
  2. Poller preserves agent_id from agent responses and adds poller_id to ServiceStatus messages.
  3. Raw data collection remains unchanged, with no local caching.
  4. OpenPorts is consistently populated in sweep data.
  5. Agent memory usage remains minimal (<1 MB for 10,000 devices).
  6. Raw data reaches the core within 5 minutes.
  7. All tests pass, including performance tests.

Dependencies

  • Coordination with core team for materialized view implementation.

Labels

  • enhancement
  • device-management
  • serviceradar-agent
  • backend
Imported from GitHub. Original GitHub issue: #769 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/issues/769 Original created: 2025-05-12T17:22:45Z --- # Enhancement: Implement Device Information Collection in ServiceRadar Agent ## Overview This issue tracks the implementation of device information collection in the `serviceradar-agent` as outlined in the [[[ServiceRadar Agent Device Caching & Reporting PRD](https://github.com/carverauto/serviceradar/tree/main/sr-architecture-and-design/prd)](https://github.com/carverauto/serviceradar/tree/main/sr-architecture-and-design/prd)](https://github.com/carverauto/serviceradar/tree/main/sr-architecture-and-design/prd). The agent will continue collecting raw `DeviceInfo` from edge services (sweep, ICMP, port, SNMP) without local caching, include `AgentID` in responses, and rely on the core service to derive the devices stream using a Proton materialized view. Pollers will attach `PollerID` to status messages, ensuring traceability. ## Description The current agent collects raw data but lacks `agent_id` and `poller_id` tracking, and a previous plan for a local `DeviceCache` raised memory footprint concerns. This implementation will: - Preserve existing raw data collection, adding only `agent_id` to `StatusResponse`. - Use existing config fields for `AgentID` and `PollerID` instead of context propagation. - Enable pollers to attach `PollerID` to service status messages. - Resolve the `OpenPorts` reference issue in the sweep service. - Minimize agent memory usage by removing all device caching code. The core service will derive the devices stream using a materialized view, aggregating and deduplicating raw data from `sweep_results`, `icmp_results`, and `snmp_results` streams. ## Implementation Tasks ### Phase 1: Core Infrastructure (Est: 3 days) - [x] Update data structures in `pkg/agent/types.go` - [x] Remove `DeviceCache`, `DeviceState`, and `DeviceCacheConfig`. - [x] Ensure `ServerConfig` includes `AgentID`. - [x] Update Protocol Buffers in `proto/serviceradar.proto` - [x] Add `agent_id` field to `StatusResponse`. - [x] Add `agent_id` and `poller_id` fields to `ServiceStatus`. - [x] Remove `DeviceStatusRequest`, `DeviceStatusResponse`, and `devices` from `PollerStatusRequest`. - [x] Generate updated gRPC code from proto definitions. ### Phase 2: Agent and Poller Updates (Est: 4 days) - [ ] Update Agent - [x] Remove `pkg/agent/devices.go` (entire file). - [x] Update `GetStatus()` in `pkg/agent/server.go` to add `AgentID` from config to `StatusResponse`. - [ ] Update edge service response handling to ensure proper raw data collection. - [x] Remove device cache initialization, maintenance, and extraction functions. - [x] Update Poller - [x] Update `ServiceCheck.execute()` in `pkg/poller/poller.go` to preserve `AgentID` from agent responses. - [x] Update `reportToCore()` to add `PollerID` to each `ServiceStatus` before reporting. - [x] Remove device-specific handling from poller methods. ### Phase 3: Testing (Est: 4 days) - [ ] Unit Tests - [ ] Test `GetStatus` for `AgentID` inclusion in `StatusResponse`. - [ ] Test `ServiceCheck.execute()` for preserving `AgentID`. - [ ] Test `reportToCore()` for adding `PollerID`. - [ ] Integration Tests - [ ] Test agent-poller communication with `agent_id` and `poller_id`. - [ ] Verify raw data consistency with existing collection. - [ ] System Tests - [ ] End-to-end test from edge services to core with `agent_id` and `poller_id`. - [ ] Performance test with 10,000+ devices, monitoring agent memory. ## Notes - Updated approach uses existing config fields for `AgentID` and `PollerID` rather than context propagation. - Preserves existing data flow and raw data collection without modification. - Focuses on identity propagation through the pipeline without changing core functionality. - Removes all device caching code to minimize memory footprint. - Relies on core service materialized view for device derivation. ## Acceptance Criteria 1. Agent includes `agent_id` in all `StatusResponse` messages. 2. Poller preserves `agent_id` from agent responses and adds `poller_id` to `ServiceStatus` messages. 3. Raw data collection remains unchanged, with no local caching. 4. `OpenPorts` is consistently populated in sweep data. 5. Agent memory usage remains minimal (<1 MB for 10,000 devices). 6. Raw data reaches the core within 5 minutes. 7. All tests pass, including performance tests. ## Dependencies - Coordination with core team for materialized view implementation. ## Labels - enhancement - device-management - serviceradar-agent - backend
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar#273
No description provided.