Update/enforce tenant schema isolation #2635
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!2635
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2635/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: #2228
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2228
Original created: 2026-01-06T23:24:53Z
Original updated: 2026-01-08T17:04:23Z
Original head: carverauto/serviceradar:update/enforce-tenant-schema-isolation
Original base: testing
Original merged: 2026-01-08T17:04:21Z 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, Bug fix, Tests
Description
Major architectural refactoring from poller to gateway model: Comprehensive rename and restructuring of the entire codebase to replace the legacy poller architecture with a modern gateway-centric design
Multi-tenant schema isolation enforcement: Implementation of tenant-scoped integrations, sources, and results storage with proper synchronization primitives across the platform
Gateway push-first communication model: Replaced pull-based result retrieval with push-based gateway communication via
pushResultsForTenantandpushHeartbeatmechanismsProtobuf schema modernization: Updated message types from
PollerIdtoGatewayId, introduced new agent-gateway communication messages (AgentHelloRequest,AgentHelloResponse,AgentConfigRequest,AgentConfigResponse), and refactored service definitions toAgentGatewayServiceComprehensive gateway monitoring implementation: New 1540-line gateway health checks, recovery detection, alert handling, and streaming status report support with chunk reassembly
NATS bootstrap CLI functionality: Added complete NATS bootstrap implementation for operator, system account, and platform account credential generation
Edge onboarding service updates: Systematic terminology updates (200+ occurrences) and support for new
EdgeOnboardingComponentTypeSynccomponent type with updated KV configuration pathsTest suite updates: Refactored sync service tests to remove deprecated KV and gRPC client mocks, updated to focus on chunking logic and gateway architecture
Sanitization and terminology consistency: Updated protected key lists and SNMP checker service to use gateway terminology
Diagram Walkthrough
File Walkthrough
6 files
monitoring.pb.go
Refactor protobuf schema from poller to gateway architectureproto/monitoring.pb.go
PollerIdfield toGatewayIdacross multiple message types(
StatusRequest,ResultsRequest,StatusResponse,ResultsResponse)PollerStatusRequest,PollerStatusResponse, andServiceStatusmessage typesPollerStatusChunkwith newGatewayStatusRequest,GatewayStatusResponse,GatewayStatusChunk, andGatewayServiceStatustypes
AgentHelloRequest,AgentHelloResponse,AgentConfigRequest,AgentConfigResponse,AgentCheckConfigTenantIdandTenantSlugfields to gateway-related messages formulti-tenant support
PollerServicetoAgentGatewayServicewith new RPC methods (
Hello,GetConfig,PushStatus,StreamStatus)nats_bootstrap.go
Add comprehensive NATS bootstrap CLI implementationpkg/cli/nats_bootstrap.go
CLI
nats-bootstrapandadmin natssubcommands withflag parsing
and verification modes
credentials and configuration files
credentials
Core API
service.go
Multi-tenant gateway push-first sync service refactoringpkg/sync/service.go
gateway push-first communication model
for push-based results and heartbeat
with proper synchronization primitives
enrollment/enrollment status tracking
GetResultsandStreamResultswith gatewaypush via
pushResultsForTenantandpushHeartbeatchunk size
gateways.go
Gateway monitoring and status management implementationpkg/core/gateways.go
implementation with 1540 lines of code
handling with caching mechanisms
reassembly and service message handling
schema isolation enforcement
edge_onboarding.go
Rename poller to gateway in edge onboarding servicepkg/core/edge_onboarding.go
edge onboarding service (200+ occurrences)
reflect gateway-centric architecture
EdgeOnboardingComponentTypeSynccomponent type inpackage creation and validation
config/pollers/toconfig/gateways/and related metadata keysmain.go
Update SNMP checker to use gateway terminologycmd/checkers/snmp/main.go
NewSNMPPollerServiceto
NewSNMPGatewayServicesnmp.Pollertosnmp.Gatewayfor consistencywith gateway terminology
1 files
main.go
Update API documentation terminologycmd/core/main.go
in Swagger documentation
2 files
prod.exs
Add production configuration for Elixir agent gatewayelixir/serviceradar_agent_gateway/config/prod.exs
infofor production environment.gitkeep
Add credentials directory placeholderdocker/compose/creds/.gitkeep
storage
2 files
nats_account.pb.go
NATS account management protobuf definitionsproto/nats_account.pb.go
generation, and JWT signing
permission management
nats_account_grpc.pb.go
NATS account service gRPC implementationproto/nats_account_grpc.pb.go
operations
and JWT signing/pushing
and interceptor support
1 files
armis_netbox_test.go
Update sync service tests for gateway architecturepkg/sync/armis_netbox_test.go
service
PollerIDreferences toGatewayIDthroughout test fixturesbuildResultsChunksinstead of full streaming
1 files
sanitize.go
Update sanitization for gateway identifierpkg/deviceupdate/sanitize.go
gateway_idinstead of deprecatedpoller_id101 files
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2228#issuecomment-3716718426
Original created: 2026-01-06T23:26:36Z
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
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/2228#issuecomment-3716723482
Original created: 2026-01-06T23:29:25Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Prevent race condition on sources
Add a read lock around the access to
s.sourcesinrunDiscoveryto prevent a datarace with concurrent configuration updates.
pkg/sync/service.go [402-415]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a data race on
s.sourcesbetweenrunDiscoveryandUpdateConfigand provides the correct fix using a read lock, preventing a potential panic.Fill gateway identifier in chunks
Populate the
GatewayIdfield inGatewayServiceStatusandGatewayStatusChunkusing the
gatewayIDfrom the service configuration.pkg/sync/service.go [1190-1238]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that
GatewayIdis being left empty in status chunks and proposes populating it from the configuration, which adds important context to the data.Skip pushes when unenrolled
In
pushResultsForTenant, handleerrGatewayNotEnrolledby returningnilto skipthe push, rather than propagating it as an error.
pkg/sync/service.go [1240-1256]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly proposes to handle
errGatewayNotEnrolledgracefully by skipping the result push instead of propagating an error, which is a more robust behavior for this specific case.Enforce critical location data validation
Return an error instead of only logging a warning when
req.PartitionorresolvedSourceIPare missing inPushStatusto enforce this critical requirement.pkg/core/gateways.go [883-890]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that logging a warning for missing critical data is insufficient and could lead to silent failures; returning an error enforces data integrity and is a significant improvement in robustness.
Improve locking for tenant store
Refactor
tenantResultsStoreto use a more efficient double-checked lockingpattern and remove a redundant nil check for
s.tenantResults.pkg/sync/service.go [1514-1534]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies an opportunity to improve the locking pattern in
tenantResultsStorefor better performance under contention and correctly points out a redundant nil check.Fix incomplete poller to gateway rename
In
resolveGatewayID, complete the refactoring from "poller" to "gateway" byupdating remaining internal strings, default values, and error types.
pkg/core/edge_onboarding.go [1578-1620]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 5
__
Why: The suggestion correctly identifies that the refactoring from
pollertogatewayis incomplete within theresolveGatewayIDfunction, and fixing these inconsistencies improves code clarity and maintainability.Use idiomatic error check for stream
In
receiveAndAssembleChunks, replace the brittleerr.Error() == "EOF"check withthe more robust and idiomatic
errors.Is(err, io.EOF).pkg/core/gateways.go [991-1038]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 4
__
Why: The suggestion correctly points out that using
errors.Is(err, io.EOF)is more robust and idiomatic than string comparison for error checking, improving code quality and maintainability.Imported GitHub PR review comment.
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2228#discussion_r2667211397
Original created: 2026-01-07T06:21:22Z
Original path: web-ng/lib/serviceradar_web_ng/edge/onboarding_events.ex
Original line: 35
hardcoded in default tenant stuff? investigating..