Cleanup/services page #2640
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2640
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2640/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2235
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2235
Original created: 2026-01-09T08:30:51Z
Original updated: 2026-01-10T00:01:38Z
Original head: carverauto/serviceradar:cleanup/services_page
Original base: testing
Original merged: 2026-01-10T00:01:36Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Enhancement, Documentation
Description
Major architectural refactoring from poller-based to gateway-based system: Comprehensive rename and restructuring of core components, services, and APIs to support a new gateway-centric architecture
Multi-tenant gateway push architecture: Refactored sync service to implement push-first integration with dynamic configuration management, replacing pull-based KV and gRPC clients with gateway client for result streaming
Gateway monitoring and status management: New comprehensive implementation for gateway health checks, offline/recovery detection, alert handling, and streaming status report processing with chunk reassembly
NATS infrastructure enhancements: Added NATS account management service with protobuf definitions and gRPC implementations for operator bootstrap, tenant account creation, and credential generation
CLI NATS bootstrap functionality: New comprehensive CLI implementation for NATS bootstrap operations including credential generation, token management, and status verification
Protobuf definitions update: Refactored protobuf messages from
PollerServicetoAgentGatewayServicewith new message types for gateway-agent communication (AgentHelloRequest,AgentConfigRequest, etc.)Edge onboarding service updates: Systematic terminology refactoring and support for new
EdgeOnboardingComponentTypeSynccomponent typeRemoved legacy poller infrastructure: Deleted poller-specific packages, CLI commands, Docker configurations, and web UI components
API documentation updates: Updated Swagger documentation and gRPC service registration to reflect gateway terminology
Diagram Walkthrough
File Walkthrough
6 files
monitoring.pb.go
Refactor protobuf definitions from poller to gateway architectureproto/monitoring.pb.go
PollerIdfield toGatewayIdacross multiple message types(
StatusRequest,ResultsRequest,StatusResponse,ResultsResponse)PollerStatusRequest,PollerStatusResponse, andServiceStatusmessage typesPollerStatusChunkwith newGatewayStatusRequest,GatewayStatusResponse, andGatewayStatusChunktypesGatewayServiceStatusmessage type with tenant-related fields(
TenantId,TenantSlug)AgentHelloRequest,AgentHelloResponse,AgentConfigRequest,AgentConfigResponse,AgentCheckConfigPollerServicetoAgentGatewayServicewith new RPC methods
nats_bootstrap.go
Add comprehensive NATS bootstrap CLI functionalitypkg/cli/nats_bootstrap.go
nats-bootstrapandadmin natssubcommands withflag parsing
verification modes
credentials and configuration files
Core API endpoints
output formatting (text/JSON)
service.go
Multi-tenant gateway push architecture with dynamic config managementpkg/sync/service.go
gateway push-first integration
for push-based results
tenant-scoped configuration
dynamic configuration management
gateway status push support
GetResultsandStreamResultsAPIs in favor ofpush-based gateway integration
gateways.go
Gateway monitoring and status management implementationpkg/core/gateways.go
implementation with 1547 lines of code
alert handling
large datasets
publishing for gateway lifecycle events
edge_onboarding.go
Poller to gateway terminology refactoringpkg/core/edge_onboarding.go
edge onboarding service
keys for consistency
EdgeOnboardingComponentTypeSynccomponent typeuse new naming
app.go
Update gRPC service registration to gateway servicecmd/core/app/app.go
RegisterPollerServiceServertoRegisterAgentGatewayServiceServer1 files
main.go
Update API documentation terminologycmd/core/main.go
in Swagger documentation
1 files
prod.exs
Add production configuration for Elixir agent gatewayelixir/serviceradar_agent_gateway/config/prod.exs
infofor production environment2 files
nats_account.pb.go
NATS account management protobuf definitions and serviceproto/nats_account.pb.go
credentials
creation, and user credential generation
infrastructure
nats_account_grpc.pb.go
NATS account gRPC service implementationproto/nats_account_grpc.pb.go
operations
operations
credential generation
framework
1 files
interfaces.go
Remove KVWriter from Armis integration mockspkg/sync/integrations/armis/interfaces.go
KVWriterfrom mockgen directive for Armis integration101 files
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2235#issuecomment-3727776562
Original created: 2026-01-09T08:32:30Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
No security concerns identified
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.🎫 No ticket provided
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status: Passed
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Limited audit context: The new onboarding log event indicates onboarding started but does not include an actor
identifier or outcome details sufficient to reconstruct who/what initiated onboarding and
whether it succeeded.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
Endpoint not validated: Environment-provided
GATEWAY_ADDRandKV_ENDPOINTvalues are only trimmed andpresence-checked, with no format/allowlist validation to prevent unsafe or unintended
endpoint injection/misconfiguration.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2235#issuecomment-3727785629
Original created: 2026-01-09T08:34:14Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Fix malformed JSON in chunking
Fix a bug in
buildResultsChunksthat creates invalid JSON by resettingdeviceCountto 0 within theflushfunction, ensuring new chunks do not startwith a leading comma.
pkg/sync/service.go [1135-1202]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 9
__
Why: This suggestion correctly identifies a critical bug that would produce malformed JSON, causing data processing to fail. The proposed fix is accurate and necessary for the feature's correctness.
✅
Prevent data race on configSuggestion Impact:
The commit updates `createIntegration` to accept a `partition` argument and updates all call sites to read `Partition` under the config lock (or from `newCfg`) and pass it in, eliminating the need to access `s.config.Partition` inside `createIntegration` without synchronization. It also adds fallback logic to use "default" when the passed partition is empty.code diff:
To prevent a data race, pass the
partitionvalue as an argument to thecreateIntegrationfunction instead of accessing the shareds.config.Partitionfield directly without a lock.
pkg/sync/service.go [1774-1797]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential data race when accessing
s.config.Partitionwithout a lock. Fixing this is crucial for concurrent safety and preventing unpredictable behavior or crashes.✅
Prevent goroutine leak on shutdownSuggestion Impact:
The select in flushGatewayStatusUpdates was updated to include a case for <-s.ShutdownChan (and an explicit return on ctx.Done), ensuring the goroutine terminates cleanly during shutdown.code diff:
Add a case for
s.ShutdownChanin theselectstatement withinflushGatewayStatusUpdatesto prevent a goroutine leak on server shutdown.pkg/core/gateways.go [161-204]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 8
__
Why: This suggestion correctly identifies a goroutine leak in
flushGatewayStatusUpdatesdue to a missing shutdown channel case. Adding a case fors.ShutdownChanis critical for ensuring graceful server shutdown and preventing resource leaks, which is a significant correctness and reliability issue.✅
Prevent goroutine leak in heartbeatSuggestion Impact:
The initial heartbeat call in heartbeatLoop was modified to use a 15s timeout context, reducing the risk of hanging indefinitely on startup. However, it was not moved into a separate goroutine, so the loop can still block until the initial heartbeat returns (up to the timeout).code diff:
To prevent the
heartbeatLoopfrom blocking on startup, run the initial heartbeatcall in a non-blocking goroutine with a separate, short-lived context.
pkg/sync/service.go [1028-1047]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that a blocking initial heartbeat can prevent the main loop from starting, improving the service's robustness against network issues during startup.
Return errors from Armis updates
Modify
runArmisUpdatesto return the collectedupdateErrorsinstead ofnil, sothat failures are propagated to the caller.
pkg/sync/service.go [687-701]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out that
runArmisUpdatesswallows errors, preventing callers from knowing if the operation failed. Returning the aggregated errors is crucial for proper error handling and observability.✅
Include GatewayId in statusSuggestion Impact:
The commit now reads gatewayID from s.config and sets GatewayServiceStatus.GatewayId to that value (replacing the previous empty string), ensuring status messages include the configured gateway ID.code diff:
Populate the
GatewayIdfield in theGatewayServiceStatusstruct using theGatewayIDfrom the service configuration instead of leaving it as an emptystring.
pkg/sync/service.go [1238-1251]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 5
__
Why: The suggestion correctly identifies that
GatewayIdis being left empty. Populating it from the configuration improves the completeness of status messages, which can be important for routing or debugging on the server side.