helm release fix, watchers and kv update #2553
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!2553
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2553/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: #2114
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2114
Original created: 2025-12-12T23:37:33Z
Original updated: 2025-12-13T00:31:27Z
Original head: carverauto/serviceradar:demo/kv_watchers_missing
Original base: main
Original merged: 2025-12-13T00:16:58Z 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
Description
Add graceful shutdown support with signal handling
Implement CNPG password file watching and hot-reload capability
Fix watcher snapshot TTL handling in KV store
Refactor service processor initialization logic
Add Helm installation step to release workflow
Diagram Walkthrough
File Walkthrough
main.go
Add CNPG password watching and graceful shutdowncmd/consumers/db-event-writer/main.go
signal.NotifyContextwatchCNPGPasswordgoroutine for monitoring password filechanges
applyCNPGPasswordto extract password file reading logicreadCNPGPasswordFilehelper function for file operationsservice.go
Refactor service initialization and add database reloadpkg/consumers/db-event-writer/service.go
buildProcessorfunction
ReloadDatabasemethod for hot-reloading database connectionsUpdateConfigto usebuildProcessorhelperwatchers_snapshot.go
Fix watcher snapshot TTL handling in KV storepkg/config/watchers_snapshot.go
WatcherSnapshotTTLconstant (rename fromwatcherSnapshotTTL)UpdatedAttimestamp for staleness detection instead of backendTTL
auth.go
Add watcher snapshot staleness validationpkg/core/api/auth.go
loadWatcherSnapshotUpdatedAtexceedsWatcherSnapshotTTLWatcherSnapshotTTLconstant for comparisonrelease.yml
Add Helm installation to release workflow.github/workflows/release.yml
azure/setup-helm@v4actionImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2114#issuecomment-3648517350
Original created: 2025-12-12T23:38:05Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Improper shutdown handling
Description: The password watcher rebuilds the database connection using context.Background() instead
of the cancellable ctx, which can bypass graceful shutdown and lead to a lingering
connection or resource leak if an attacker triggers repeated password change events.
main.go [238-246]
Referred Code
Resource leak risk
Description: On CNPG password change, the old database handle is only closed when ReloadDatabase
succeeds; if ReloadDatabase fails, the newly created handle is closed but the original
connection remains with an invalid password, potentially causing prolonged failed retries
and resource exhaustion.
main.go [232-256]
Referred Code
Stale data persistence
Description: Changing KV Put TTL to 0 makes snapshot entries persistent; without backend-enforced
expiration, a misconfigured or compromised writer could leave stale records indefinitely,
increasing the risk of stale data being served if readers fail to enforce staleness
correctly elsewhere.
watchers_snapshot.go [52-55]
Referred 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: 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:
Missing audit logs: New critical actions like CNPG password reload and service restart are performed without
explicit audit-style logging that captures actor/context beyond generic messages.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Context misuse: Database rebuild on password change uses context.Background() instead of the request
context, potentially bypassing cancellation and timeouts on shutdown.
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:
Secret handling: Password file contents are read and used without explicit permission checks or file mode
validation, which may risk insecure secret handling.
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/2114#issuecomment-3648519165
Original created: 2025-12-12T23:39:05Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Simplify password rotation via orchestration
Remove the custom logic for hot-reloading database passwords. Instead, rely on
an orchestration platform like Kubernetes to handle password rotation by
automatically restarting the application pod when its secrets are updated.
Examples:
cmd/consumers/db-event-writer/main.go [195-259]
pkg/consumers/db-event-writer/service.go [152-179]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 9
__
Why: This is an excellent architectural suggestion that correctly identifies significant new complexity and proposes a simpler, more robust, industry-standard alternative that simplifies application state management.
Use cancellable context for database connection
In the
watchCNPGPasswordfunction, replacecontext.Background()with thecancellable
ctxwhen callingdb.Newto ensure the operation can be abortedduring application shutdown.
cmd/consumers/db-event-writer/main.go [236-244]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a bug where using
context.Background()in a cancellable goroutine can prevent graceful shutdown. Propagating thectxis the correct fix and improves service reliability.