Bug/docker compose not creating db #2539

Merged
mfreeman451 merged 4 commits from refs/pull/2539/head into main 2025-12-10 21:00:00 +00:00
mfreeman451 commented 2025-12-10 19:01:06 +00:00 (Migrated from github.com)
Owner

Imported from GitHub pull request.

Original GitHub pull request: #2098
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2098
Original created: 2025-12-10T19:01:06Z
Original updated: 2026-01-28T21:47:17Z
Original head: carverauto/serviceradar:bug/docker_compose_not_creating_db
Original base: main
Original merged: 2025-12-10T21:00:00Z 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:

Signed-off-by: J. Doe <j.doe@domain.com>

Describe your changes

Code checklist before requesting a review

  • I have signed the DCO?
  • The build completes without errors?
  • All tests are passing when running make test?

PR Type

Bug fix


Description

  • Upgrade CNPG image to 16.6.0-sr3 with stable TimescaleDB 2.24.0

  • Remove version override hack forcing 2.24.0-dev in build

  • Add cert-generator dependency to docker-compose services

  • Disable retention policy creation in migrations as workaround


Diagram Walkthrough

flowchart LR
  A["Old CNPG Image<br/>16.6.0-sr2<br/>TimescaleDB 2.24.0-dev"] -->|"Version override<br/>in BUILD.bazel"| B["Broken retention<br/>policy creation"]
  B -->|"SIGABRT crash<br/>in retention_api.c"| C["Fresh docker-compose<br/>deployments fail"]
  D["Remove version<br/>override hack"] -->|"Use native<br/>TimescaleDB 2.24.0"| E["New CNPG Image<br/>16.6.0-sr3<br/>TimescaleDB 2.24.0"]
  E -->|"Stable release"| F["Retention policies<br/>work correctly"]
  F -->|"Migrations succeed"| G["Fresh deployments<br/>succeed"]

File Walkthrough

Relevant files
Bug fix
7 files
BUILD.bazel
Remove TimescaleDB version override in build                         
+0/-6     
docker-compose.yml
Update CNPG image tag and add dependencies                             
+5/-2     
docker-compose.podman.yml
Update CNPG image tag and add dependencies                             
+4/-1     
podman-start.sh
Update CNPG image tag to 16.6.0-sr3                                           
+1/-1     
Dockerfile.rbe
Update CNPG image reference in build                                         
+1/-1     
Dockerfile.rbe-ora9
Update CNPG image reference in build                                         
+1/-1     
00000000000001_schema.up.sql
Disable all retention policy creation calls                           
+22/-22 
Configuration changes
4 files
push_targets.bzl
Update CNPG image tag in push targets                                       
+1/-1     
values.yaml
Update CNPG image tag and SHA digest                                         
+1/-1     
cnpg-cluster.yaml
Update CNPG image tag and SHA digest                                         
+1/-1     
cnpg-cluster.yaml
Update CNPG image tag and SHA digest                                         
+1/-1     
Documentation
5 files
agents.md
Update CNPG image reference in documentation                         
+1/-1     
README.md
Update CNPG image reference in documentation                         
+1/-1     
proposal.md
Document root cause and fix for TimescaleDB bug                   
+32/-0   
spec.md
Add requirements for stable TimescaleDB releases                 
+32/-0   
tasks.md
Document completed tasks for version fix                                 
+36/-0   

Imported from GitHub pull request. Original GitHub pull request: #2098 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/pull/2098 Original created: 2025-12-10T19:01:06Z Original updated: 2026-01-28T21:47:17Z Original head: carverauto/serviceradar:bug/docker_compose_not_creating_db Original base: main Original merged: 2025-12-10T21:00:00Z 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]( https://developercertificate.org/) indicating the DCO acceptance in one commit message. Here is an example DCO Signed-off-by line in a commit message: ``` Signed-off-by: J. Doe <j.doe@domain.com> ``` ## Describe your changes ## Issue ticket number and link ## Code checklist before requesting a review - [ ] I have signed the DCO? - [ ] The build completes without errors? - [ ] All tests are passing when running make test? ___ ### **PR Type** Bug fix ___ ### **Description** - Upgrade CNPG image to 16.6.0-sr3 with stable TimescaleDB 2.24.0 - Remove version override hack forcing 2.24.0-dev in build - Add cert-generator dependency to docker-compose services - Disable retention policy creation in migrations as workaround ___ ### Diagram Walkthrough ```mermaid flowchart LR A["Old CNPG Image<br/>16.6.0-sr2<br/>TimescaleDB 2.24.0-dev"] -->|"Version override<br/>in BUILD.bazel"| B["Broken retention<br/>policy creation"] B -->|"SIGABRT crash<br/>in retention_api.c"| C["Fresh docker-compose<br/>deployments fail"] D["Remove version<br/>override hack"] -->|"Use native<br/>TimescaleDB 2.24.0"| E["New CNPG Image<br/>16.6.0-sr3<br/>TimescaleDB 2.24.0"] E -->|"Stable release"| F["Retention policies<br/>work correctly"] F -->|"Migrations succeed"| G["Fresh deployments<br/>succeed"] ``` <details><summary><h3>File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><details><summary>7 files</summary><table> <tr> <td><strong>BUILD.bazel</strong><dd><code>Remove TimescaleDB version override in build</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-0e4db31c224a8f72ae8e870a849e38a59d74a2c7f7b04347b0b3eb07e20c5a80">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>docker-compose.yml</strong><dd><code>Update CNPG image tag and add dependencies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-e45e45baeda1c1e73482975a664062aa56f20c03dd9d64a827aba57775bed0d3">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>docker-compose.podman.yml</strong><dd><code>Update CNPG image tag and add dependencies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-77a7fc5fac1d23ddc900d0f5128aedde1fe22302ba66820a704a8e5d13a15dbb">+4/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>podman-start.sh</strong><dd><code>Update CNPG image tag to 16.6.0-sr3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-b535a8cc079d7b11e8171badcb8d2e359d82db6b2903c688fa463798f9e7a154">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>Dockerfile.rbe</strong><dd><code>Update CNPG image reference in build</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-40936cbae5822a0a5fa8016befa08eb3a7836c93328e8043dcdfb3885a6201b2">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>Dockerfile.rbe-ora9</strong><dd><code>Update CNPG image reference in build</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-c4a73a282f345855c6c173679a1f3dcf26b8cc70e3a0f026bdb0ab0a40b6834d">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>00000000000001_schema.up.sql</strong><dd><code>Disable all retention policy creation calls</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-6a6f36e8670865c966dffe617122eec32dd034277ea0832973c5e79f359b7805">+22/-22</a>&nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>push_targets.bzl</strong><dd><code>Update CNPG image tag in push targets</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-4af33fe62caba04b6d479589c16cfb85babc39bae5c92595d4d4e31660738513">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>values.yaml</strong><dd><code>Update CNPG image tag and SHA digest</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-d4449c7cb70362554b274f81eae5a4b81a8e81df494282e383d1b7ea3871c452">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>cnpg-cluster.yaml</strong><dd><code>Update CNPG image tag and SHA digest</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-7295774b8f05fee8f0f2b054f94381aa4c2581344117e9386f62c50baf64de53">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>cnpg-cluster.yaml</strong><dd><code>Update CNPG image tag and SHA digest</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-760bce255f2a46e053d34785cde7ee863372ea085f28f42b45858e2ca066079f">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>5 files</summary><table> <tr> <td><strong>agents.md</strong><dd><code>Update CNPG image reference in documentation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-af8d04277f2353629065b0cc5fad3e44bd3e7c20339bd125e0812104bdbeff28">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>README.md</strong><dd><code>Update CNPG image reference in documentation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-a8ab6f0cb1e9ce4a1dd84e4ebadfa1b588c91ab4187fcbe5c57ce11749fbdff1">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>proposal.md</strong><dd><code>Document root cause and fix for TimescaleDB bug</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-c63ff67b2df6ce90168759f5124c95908cb7fd27487e49857cdb7fbc800855d3">+32/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>spec.md</strong><dd><code>Add requirements for stable TimescaleDB releases</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-2d0583ff0ff0a6ca6ef634a33e06102bf5d29048e120d218c07ab3c7fccbc71e">+32/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>tasks.md</strong><dd><code>Document completed tasks for version fix</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-7b1086f0fff9d03a90aec6e9bbed17fdd1501f8fd14f4485077d0159eba86d30">+36/-0</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr></tbody></table> </details> ___
qodo-code-review[bot] commented 2025-12-10 19:01:43 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2098#issuecomment-3638545503
Original created: 2025-12-10T19:01:43Z

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

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

Learn more about managing compliance generic rules or creating your own custom rules

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

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Audit retention disabled: Newly added lines disable TimescaleDB retention policies for many audit-relevant tables
(e.g., events, logs, service_registration_events), which may impact the ability to retain
and reconstruct audit trails unless alternative retention or archival exists.

Referred Code
-- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);
CREATE INDEX IF NOT EXISTS idx_timeseries_metrics_device_time ON timeseries_metrics (device_id, timestamp DESC);

CREATE TABLE IF NOT EXISTS cpu_metrics (
    timestamp           TIMESTAMPTZ       NOT NULL,
    poller_id           TEXT              NOT NULL,
    agent_id            TEXT,
    host_id             TEXT,
    core_id             INTEGER,
    usage_percent       DOUBLE PRECISION,
    frequency_hz        DOUBLE PRECISION,
    label               TEXT,
    cluster             TEXT,
    device_id           TEXT,
    partition           TEXT,
    created_at          TIMESTAMPTZ       NOT NULL DEFAULT now()
);
SELECT create_hypertable('cpu_metrics','timestamp', if_not_exists => TRUE);
-- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);
CREATE INDEX IF NOT EXISTS idx_cpu_metrics_device_time ON cpu_metrics (device_id, timestamp DESC);



 ... (clipped 544 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Disabled safeguards: The PR comments out retention policy creation across multiple hypertables as a workaround
for crashes, which defers an edge-case handling strategy without providing alternative
safeguards or migration-time checks for policy existence.

Referred Code
-- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);
CREATE INDEX IF NOT EXISTS idx_timeseries_metrics_device_time ON timeseries_metrics (device_id, timestamp DESC);

CREATE TABLE IF NOT EXISTS cpu_metrics (
    timestamp           TIMESTAMPTZ       NOT NULL,
    poller_id           TEXT              NOT NULL,
    agent_id            TEXT,
    host_id             TEXT,
    core_id             INTEGER,
    usage_percent       DOUBLE PRECISION,
    frequency_hz        DOUBLE PRECISION,
    label               TEXT,
    cluster             TEXT,
    device_id           TEXT,
    partition           TEXT,
    created_at          TIMESTAMPTZ       NOT NULL DEFAULT now()
);
SELECT create_hypertable('cpu_metrics','timestamp', if_not_exists => TRUE);
-- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);
CREATE INDEX IF NOT EXISTS idx_cpu_metrics_device_time ON cpu_metrics (device_id, timestamp DESC);



 ... (clipped 544 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
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/2098#issuecomment-3638545503 Original created: 2025-12-10T19:01:43Z --- ## PR Compliance Guide 🔍 <!-- https://github.com/carverauto/serviceradar/commit/52bc788bd2ea54542e2bb25ddcbb99282e6ac32f --> Below is a summary of compliance checks for this PR:<br> <table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr> <tr><td>🟢</td><td><details><summary><strong>No security concerns identified</strong></summary> No security vulnerabilities detected by AI analysis. Human verification advised for critical code. </details></td></tr> <tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary>🎫 <strong>No ticket provided </strong></summary> - [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true --> </details></td></tr> <tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks. </details></td></tr> <tr><td colspan='2'><strong>Custom Compliance</strong></td></tr> <tr><td rowspan=4>🟢</td><td> <details><summary><strong>Generic: Meaningful Naming and Self-Documenting Code</strong></summary><br> **Objective:** Ensure all identifiers clearly express their purpose and intent, making code <br>self-documenting<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Error Handling</strong></summary><br> **Objective:** To prevent the leakage of sensitive system information through error messages while <br>providing sufficient detail for internal debugging.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Logging Practices</strong></summary><br> **Objective:** To ensure logs are useful for debugging and auditing without exposing sensitive <br>information like PII, PHI, or cardholder data.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Security-First Input Validation and Data Handling</strong></summary><br> **Objective:** Ensure all data inputs are validated, sanitized, and handled securely to prevent <br>vulnerabilities<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td rowspan=2>⚪</td> <td><details> <summary><strong>Generic: Comprehensive Audit Trails</strong></summary><br> **Objective:** To create a detailed and reliable record of critical system actions for security analysis <br>and compliance.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/2098/files#diff-6a6f36e8670865c966dffe617122eec32dd034277ea0832973c5e79f359b7805R34-R598'><strong>Audit retention disabled</strong></a>: Newly added lines disable TimescaleDB retention policies for many audit-relevant tables <br>(e.g., events, logs, service_registration_events), which may impact the ability to retain <br>and reconstruct audit trails unless alternative retention or archival exists.<br> <details open><summary>Referred Code</summary> ```sql -- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_timeseries_metrics_device_time ON timeseries_metrics (device_id, timestamp DESC); CREATE TABLE IF NOT EXISTS cpu_metrics ( timestamp TIMESTAMPTZ NOT NULL, poller_id TEXT NOT NULL, agent_id TEXT, host_id TEXT, core_id INTEGER, usage_percent DOUBLE PRECISION, frequency_hz DOUBLE PRECISION, label TEXT, cluster TEXT, device_id TEXT, partition TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); SELECT create_hypertable('cpu_metrics','timestamp', if_not_exists => TRUE); -- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_cpu_metrics_device_time ON cpu_metrics (device_id, timestamp DESC); ... (clipped 544 lines) ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td><details> <summary><strong>Generic: Robust Error Handling and Edge Case Management</strong></summary><br> **Objective:** Ensure comprehensive error handling that provides meaningful context and graceful <br>degradation<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/2098/files#diff-6a6f36e8670865c966dffe617122eec32dd034277ea0832973c5e79f359b7805R34-R598'><strong>Disabled safeguards</strong></a>: The PR comments out retention policy creation across multiple hypertables as a workaround <br>for crashes, which defers an edge-case handling strategy without providing alternative <br>safeguards or migration-time checks for policy existence.<br> <details open><summary>Referred Code</summary> ```sql -- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_timeseries_metrics_device_time ON timeseries_metrics (device_id, timestamp DESC); CREATE TABLE IF NOT EXISTS cpu_metrics ( timestamp TIMESTAMPTZ NOT NULL, poller_id TEXT NOT NULL, agent_id TEXT, host_id TEXT, core_id INTEGER, usage_percent DOUBLE PRECISION, frequency_hz DOUBLE PRECISION, label TEXT, cluster TEXT, device_id TEXT, partition TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); SELECT create_hypertable('cpu_metrics','timestamp', if_not_exists => TRUE); -- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_cpu_metrics_device_time ON cpu_metrics (device_id, timestamp DESC); ... (clipped 544 lines) ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td align="center" colspan="2"> - [ ] Update <!-- /compliance --update_compliance=true --> </td></tr></tbody></table> <details><summary>Compliance status legend</summary> 🟢 - Fully Compliant<br> 🟡 - Partial Compliant<br> 🔴 - Not Compliant<br> ⚪ - Requires Further Human Verification<br> 🏷️ - Compliance label<br> </details>
qodo-code-review[bot] commented 2025-12-10 19:03:01 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2098#issuecomment-3638549926
Original created: 2025-12-10T19:03:01Z

PR Code Suggestions

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
The PR disables retention policies, contradicting the fix's goal

The PR's fix for a database migration crash is flawed because it disables all
retention policy creation in the SQL migration file. This workaround introduces
a significant regression that will cause unbounded data growth and should be
reverted.

Examples:

pkg/db/cnpg/migrations/00000000000001_schema.up.sql [34]
-- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);
pkg/db/cnpg/migrations/00000000000001_schema.up.sql [52]
-- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);

Solution Walkthrough:

Before:

-- In pkg/db/cnpg/migrations/00000000000001_schema.up.sql

-- ... create hypertable timeseries_metrics ...
-- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);

-- ... create hypertable cpu_metrics ...
-- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);

-- ... create hypertable disk_metrics ...
-- DISABLED: SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE);

-- ... (and so on for all hypertables)

After:

-- In pkg/db/cnpg/migrations/00000000000001_schema.up.sql

-- ... create hypertable timeseries_metrics ...
SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);

-- ... create hypertable cpu_metrics ...
SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);

-- ... create hypertable disk_metrics ...
SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE);

-- ... (and so on for all hypertables, assuming the image upgrade actually fixed the crash)

Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies a critical flaw where the PR claims to fix retention policy creation but instead disables it entirely, which is a major regression causing unbounded data growth.

High
Possible issue
Re-enable disabled data retention policies

Re-enable the add_retention_policy() calls in the SQL migration script. These
were commented out but should be active now that the underlying bug is fixed by
the new CNPG image.

pkg/db/cnpg/migrations/00000000000001_schema.up.sql [33-599]

 SELECT create_hypertable('timeseries_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_timeseries_metrics_device_time ON timeseries_metrics (device_id, timestamp DESC);
 
 CREATE TABLE IF NOT EXISTS cpu_metrics (
 ...
 );
 SELECT create_hypertable('cpu_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_cpu_metrics_device_time ON cpu_metrics (device_id, timestamp DESC);
 
 CREATE TABLE IF NOT EXISTS cpu_cluster_metrics (
 ...
 );
 SELECT create_hypertable('cpu_cluster_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('cpu_cluster_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('cpu_cluster_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 
 CREATE TABLE IF NOT EXISTS disk_metrics (
 ...
 );
 SELECT create_hypertable('disk_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 
 CREATE TABLE IF NOT EXISTS memory_metrics (
 ...
 );
 SELECT create_hypertable('memory_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('memory_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('memory_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 
 CREATE TABLE IF NOT EXISTS process_metrics (
 ...
 );
 SELECT create_hypertable('process_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('process_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('process_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 
 CREATE TABLE IF NOT EXISTS netflow_metrics (
 ...
 );
 SELECT create_hypertable('netflow_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('netflow_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('netflow_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 
 -- ================================
 -- Discovery + sweep data
 -- ================================
 ...
 );
 SELECT create_hypertable('sweep_host_states','last_sweep_time', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('sweep_host_states', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('sweep_host_states', INTERVAL '3 days', if_not_exists => TRUE);
 
 CREATE TABLE IF NOT EXISTS discovered_interfaces (
 ...
 );
 SELECT create_hypertable('discovered_interfaces','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('discovered_interfaces', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('discovered_interfaces', INTERVAL '3 days', if_not_exists => TRUE);
 
 CREATE TABLE IF NOT EXISTS topology_discovery_events (
 ...
 );
 SELECT create_hypertable('topology_discovery_events','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('topology_discovery_events', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('topology_discovery_events', INTERVAL '3 days', if_not_exists => TRUE);
 
 -- ================================
 -- Device inventory + updates
 -- ================================
 ...
 );
 SELECT create_hypertable('device_updates','observed_at', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('device_updates', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('device_updates', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_device_updates_device_time ON device_updates (device_id, observed_at DESC);
 
 CREATE TABLE IF NOT EXISTS unified_devices (
 ...
 );
 SELECT create_hypertable('service_registration_events','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('service_registration_events', INTERVAL '90 days', if_not_exists => TRUE);
+SELECT add_retention_policy('service_registration_events', INTERVAL '90 days', if_not_exists => TRUE);
 
 -- ================================
 -- Poller/service history
 -- ================================
 ...
 );
 SELECT create_hypertable('poller_history','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('poller_history', INTERVAL '7 days', if_not_exists => TRUE);
+SELECT add_retention_policy('poller_history', INTERVAL '7 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_poller_history_id_time ON poller_history (poller_id, timestamp DESC);
 
 CREATE TABLE IF NOT EXISTS service_status (
 ...
 );
 SELECT create_hypertable('service_status','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('service_status', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('service_status', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_service_status_identity ON service_status (poller_id, service_name, timestamp DESC);
 
 CREATE TABLE IF NOT EXISTS services (
 ...
 );
 SELECT create_hypertable('services','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('services', INTERVAL '30 days', if_not_exists => TRUE);
+SELECT add_retention_policy('services', INTERVAL '30 days', if_not_exists => TRUE);
 
 -- ================================
 -- Edge onboarding
 -- ================================
 ...
 );
 SELECT create_hypertable('edge_onboarding_events','event_time', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('edge_onboarding_events', INTERVAL '365 days', if_not_exists => TRUE);
+SELECT add_retention_policy('edge_onboarding_events', INTERVAL '365 days', if_not_exists => TRUE);
 
 -- ================================
 -- Device capability registry
 -- ================================
 ...
 );
 SELECT create_hypertable('device_capabilities','last_checked', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('device_capabilities', INTERVAL '90 days', if_not_exists => TRUE);
+SELECT add_retention_policy('device_capabilities', INTERVAL '90 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_device_capabilities_lookup ON device_capabilities (device_id, capability, service_id, last_checked DESC);
 
 CREATE TABLE IF NOT EXISTS device_capability_registry (
 ...
 );
 SELECT create_hypertable('events','event_timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('events', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('events', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE UNIQUE INDEX IF NOT EXISTS idx_events_id_unique ON events (id, event_timestamp);
 ...
 );
 SELECT create_hypertable('rperf_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('rperf_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('rperf_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_rperf_metrics_poller_time ON rperf_metrics (poller_id, timestamp DESC);
 ...
 );
 SELECT create_hypertable('logs','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('logs', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('logs', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_logs_service_time ON logs (service_name, timestamp DESC);
 ...
 );
 SELECT create_hypertable('otel_metrics','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('otel_metrics', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('otel_metrics', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_otel_metrics_service_time ON otel_metrics (service_name, timestamp DESC);
 ...
 );
 SELECT create_hypertable('otel_traces','timestamp', if_not_exists => TRUE);
--- DISABLED: SELECT add_retention_policy('otel_traces', INTERVAL '3 days', if_not_exists => TRUE);
+SELECT add_retention_policy('otel_traces', INTERVAL '3 days', if_not_exists => TRUE);
 CREATE INDEX IF NOT EXISTS idx_otel_traces_trace_id ON otel_traces (trace_id);

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 10

__

Why: This suggestion correctly identifies that the PR's primary goal of fixing retention policies is undermined by leaving the add_retention_policy() calls commented out, which would lead to a critical data growth issue.

High
Ensure service waits for dependency completion

In docker-compose.podman.yml, modify the depends_on for the cnpg service to wait
for cert-generator to complete successfully, preventing a race condition.

docker-compose.podman.yml [19-20]

 depends_on:
   cert-generator:
+    condition: service_completed_successfully
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a potential race condition in docker-compose.podman.yml and proposes a fix that aligns it with docker-compose.yml, preventing likely startup failures and improving service reliability.

Medium
  • Update
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/2098#issuecomment-3638549926 Original created: 2025-12-10T19:03:01Z --- ## PR Code Suggestions ✨ <!-- 52bc788 --> Explore these optional code suggestions: <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>High-level</td> <td> <details><summary>The PR disables retention policies, contradicting the fix's goal</summary> ___ **The PR's fix for a database migration crash is flawed because it disables all <br>retention policy creation in the SQL migration file. This workaround introduces <br>a significant regression that will cause unbounded data growth and should be <br>reverted.** ### Examples: <details> <summary> <a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-6a6f36e8670865c966dffe617122eec32dd034277ea0832973c5e79f359b7805R34-R34">pkg/db/cnpg/migrations/00000000000001_schema.up.sql [34]</a> </summary> ```sql -- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); ``` </details> <details> <summary> <a href="https://github.com/carverauto/serviceradar/pull/2098/files#diff-6a6f36e8670865c966dffe617122eec32dd034277ea0832973c5e79f359b7805R52-R52">pkg/db/cnpg/migrations/00000000000001_schema.up.sql [52]</a> </summary> ```sql -- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); ``` </details> ### Solution Walkthrough: #### Before: ```sql -- In pkg/db/cnpg/migrations/00000000000001_schema.up.sql -- ... create hypertable timeseries_metrics ... -- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ... create hypertable cpu_metrics ... -- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ... create hypertable disk_metrics ... -- DISABLED: SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ... (and so on for all hypertables) ``` #### After: ```sql -- In pkg/db/cnpg/migrations/00000000000001_schema.up.sql -- ... create hypertable timeseries_metrics ... SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ... create hypertable cpu_metrics ... SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ... create hypertable disk_metrics ... SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ... (and so on for all hypertables, assuming the image upgrade actually fixed the crash) ``` <details><summary>Suggestion importance[1-10]: 10</summary> __ Why: The suggestion correctly identifies a critical flaw where the PR claims to fix retention policy creation but instead disables it entirely, which is a major regression causing unbounded data growth. </details></details></td><td align=center>High </td></tr><tr><td rowspan=2>Possible issue</td> <td> <details><summary>Re-enable disabled data retention policies</summary> ___ **Re-enable the <code>add_retention_policy()</code> calls in the SQL migration script. These <br>were commented out but should be active now that the underlying bug is fixed by <br>the new CNPG image.** [pkg/db/cnpg/migrations/00000000000001_schema.up.sql [33-599]](https://github.com/carverauto/serviceradar/pull/2098/files#diff-6a6f36e8670865c966dffe617122eec32dd034277ea0832973c5e79f359b7805R33-R599) ```diff SELECT create_hypertable('timeseries_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('timeseries_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_timeseries_metrics_device_time ON timeseries_metrics (device_id, timestamp DESC); CREATE TABLE IF NOT EXISTS cpu_metrics ( ... ); SELECT create_hypertable('cpu_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('cpu_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_cpu_metrics_device_time ON cpu_metrics (device_id, timestamp DESC); CREATE TABLE IF NOT EXISTS cpu_cluster_metrics ( ... ); SELECT create_hypertable('cpu_cluster_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('cpu_cluster_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('cpu_cluster_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE TABLE IF NOT EXISTS disk_metrics ( ... ); SELECT create_hypertable('disk_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('disk_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE TABLE IF NOT EXISTS memory_metrics ( ... ); SELECT create_hypertable('memory_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('memory_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('memory_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE TABLE IF NOT EXISTS process_metrics ( ... ); SELECT create_hypertable('process_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('process_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('process_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE TABLE IF NOT EXISTS netflow_metrics ( ... ); SELECT create_hypertable('netflow_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('netflow_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('netflow_metrics', INTERVAL '3 days', if_not_exists => TRUE); -- ================================ -- Discovery + sweep data -- ================================ ... ); SELECT create_hypertable('sweep_host_states','last_sweep_time', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('sweep_host_states', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('sweep_host_states', INTERVAL '3 days', if_not_exists => TRUE); CREATE TABLE IF NOT EXISTS discovered_interfaces ( ... ); SELECT create_hypertable('discovered_interfaces','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('discovered_interfaces', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('discovered_interfaces', INTERVAL '3 days', if_not_exists => TRUE); CREATE TABLE IF NOT EXISTS topology_discovery_events ( ... ); SELECT create_hypertable('topology_discovery_events','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('topology_discovery_events', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('topology_discovery_events', INTERVAL '3 days', if_not_exists => TRUE); -- ================================ -- Device inventory + updates -- ================================ ... ); SELECT create_hypertable('device_updates','observed_at', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('device_updates', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('device_updates', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_device_updates_device_time ON device_updates (device_id, observed_at DESC); CREATE TABLE IF NOT EXISTS unified_devices ( ... ); SELECT create_hypertable('service_registration_events','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('service_registration_events', INTERVAL '90 days', if_not_exists => TRUE); +SELECT add_retention_policy('service_registration_events', INTERVAL '90 days', if_not_exists => TRUE); -- ================================ -- Poller/service history -- ================================ ... ); SELECT create_hypertable('poller_history','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('poller_history', INTERVAL '7 days', if_not_exists => TRUE); +SELECT add_retention_policy('poller_history', INTERVAL '7 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_poller_history_id_time ON poller_history (poller_id, timestamp DESC); CREATE TABLE IF NOT EXISTS service_status ( ... ); SELECT create_hypertable('service_status','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('service_status', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('service_status', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_service_status_identity ON service_status (poller_id, service_name, timestamp DESC); CREATE TABLE IF NOT EXISTS services ( ... ); SELECT create_hypertable('services','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('services', INTERVAL '30 days', if_not_exists => TRUE); +SELECT add_retention_policy('services', INTERVAL '30 days', if_not_exists => TRUE); -- ================================ -- Edge onboarding -- ================================ ... ); SELECT create_hypertable('edge_onboarding_events','event_time', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('edge_onboarding_events', INTERVAL '365 days', if_not_exists => TRUE); +SELECT add_retention_policy('edge_onboarding_events', INTERVAL '365 days', if_not_exists => TRUE); -- ================================ -- Device capability registry -- ================================ ... ); SELECT create_hypertable('device_capabilities','last_checked', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('device_capabilities', INTERVAL '90 days', if_not_exists => TRUE); +SELECT add_retention_policy('device_capabilities', INTERVAL '90 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_device_capabilities_lookup ON device_capabilities (device_id, capability, service_id, last_checked DESC); CREATE TABLE IF NOT EXISTS device_capability_registry ( ... ); SELECT create_hypertable('events','event_timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('events', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('events', INTERVAL '3 days', if_not_exists => TRUE); CREATE UNIQUE INDEX IF NOT EXISTS idx_events_id_unique ON events (id, event_timestamp); ... ); SELECT create_hypertable('rperf_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('rperf_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('rperf_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_rperf_metrics_poller_time ON rperf_metrics (poller_id, timestamp DESC); ... ); SELECT create_hypertable('logs','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('logs', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('logs', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_logs_service_time ON logs (service_name, timestamp DESC); ... ); SELECT create_hypertable('otel_metrics','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('otel_metrics', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('otel_metrics', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_otel_metrics_service_time ON otel_metrics (service_name, timestamp DESC); ... ); SELECT create_hypertable('otel_traces','timestamp', if_not_exists => TRUE); --- DISABLED: SELECT add_retention_policy('otel_traces', INTERVAL '3 days', if_not_exists => TRUE); +SELECT add_retention_policy('otel_traces', INTERVAL '3 days', if_not_exists => TRUE); CREATE INDEX IF NOT EXISTS idx_otel_traces_trace_id ON otel_traces (trace_id); ``` `[To ensure code accuracy, apply this suggestion manually]` <details><summary>Suggestion importance[1-10]: 10</summary> __ Why: This suggestion correctly identifies that the PR's primary goal of fixing retention policies is undermined by leaving the `add_retention_policy()` calls commented out, which would lead to a critical data growth issue. </details></details></td><td align=center>High </td></tr><tr><td> <details><summary>Ensure service waits for dependency completion</summary> ___ **In <code>docker-compose.podman.yml</code>, modify the <code>depends_on</code> for the <code>cnpg</code> service to wait <br>for <code>cert-generator</code> to complete successfully, preventing a race condition.** [docker-compose.podman.yml [19-20]](https://github.com/carverauto/serviceradar/pull/2098/files#diff-77a7fc5fac1d23ddc900d0f5128aedde1fe22302ba66820a704a8e5d13a15dbbR19-R20) ```diff depends_on: cert-generator: + condition: service_completed_successfully ``` - [ ] **Apply / Chat** <!-- /improve --apply_suggestion=2 --> <details><summary>Suggestion importance[1-10]: 8</summary> __ Why: The suggestion correctly identifies a potential race condition in `docker-compose.podman.yml` and proposes a fix that aligns it with `docker-compose.yml`, preventing likely startup failures and improving service reliability. </details></details></td><td align=center>Medium </td></tr> <tr><td align="center" colspan="2"> - [ ] Update <!-- /improve_multi --more_suggestions=true --> </td><td></td></tr></tbody></table>
Sign in to join this conversation.
No reviewers
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!2539
No description provided.