feat: add support for rule engine system credential#1512
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds EVENT_PERSISTENCE_* defaults, updates the create_initial_data management command to validate persistence settings and create/update a managed Rule Engine credential (password or certificate auth, reads TLS files), adds unit tests for these flows, and updates Docker Compose plus a Postgres init script to provision the persistence DB. Changes
Sequence Diagram(s)sequenceDiagram
participant Cmd as create_initial_data.Command
participant Settings as Settings
participant FS as Filesystem
participant ORM as Django ORM
Cmd->>Settings: read EVENT_PERSISTENCE_* values
Cmd->>Cmd: return early if host unset
Cmd->>Cmd: validate required settings or raise ImproperlyConfigured
alt cert auth configured
Cmd->>FS: read EVENT_PERSISTENCE_PGSSLCERT
Cmd->>FS: read EVENT_PERSISTENCE_PGSSLKEY
opt EVENT_PERSISTENCE_PGSSLROOTCERT provided
Cmd->>FS: read EVENT_PERSISTENCE_PGSSLROOTCERT
end
end
Cmd->>ORM: resolve CredentialType(EDA_RULE_ENGINE)
Cmd->>ORM: create/update managed EdaCredential with computed inputs
ORM-->>Cmd: persist credential
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tools/docker/postgres/initdb.d/create_event_persistence_db.sh`:
- Around line 1-8: The script create_event_persistence_db.sh currently hardcodes
'eda_event_persistence' in the psql query; update it to use the environment
variable EDA_EVENT_PERSISTENCE_DB_NAME (with a sensible default like
eda_event_persistence) instead of the literal string. Read and sanitize/quote
the shell variable (e.g., set a default via parameter expansion) and substitute
that variable into the SELECT ... WHERE NOT EXISTS (... datname = '...')\gexec
block so the psql command creates the configured DB name used by the
application.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9070a890-6526-45a9-afd1-2af27213f256
📒 Files selected for processing (7)
src/aap_eda/core/management/commands/create_initial_data.pysrc/aap_eda/settings/defaults.pytests/unit/commands/test_create_initial_data.pytools/docker/docker-compose-dev.yamltools/docker/docker-compose-mac.ymltools/docker/docker-compose-stage.yamltools/docker/postgres/initdb.d/create_event_persistence_db.sh
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1512 +/- ##
==========================================
+ Coverage 91.89% 91.92% +0.02%
==========================================
Files 239 239
Lines 10763 10794 +31
==========================================
+ Hits 9891 9922 +31
Misses 872 872
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
d3b4350 to
e510dc3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tools/docker/docker-compose-dev.yaml`:
- Around line 54-58: Update the docker-compose postgres service to pass the
EDA_EVENT_PERSISTENCE_DB_NAME and EDA_EVENT_PERSISTENCE_DB_USER environment
variables into the container (so the init script sees the configured values) and
then modify the init script create_event_persistence_db.sh to reference
$EDA_EVENT_PERSISTENCE_DB_USER and $EDA_EVENT_PERSISTENCE_DB_NAME (instead of
the hardcoded OWNER eda) and ensure the script creates or verifies the role
exists before assigning ownership; target the env vars
EDA_EVENT_PERSISTENCE_DB_NAME / EDA_EVENT_PERSISTENCE_DB_USER and the init
script create_event_persistence_db.sh for these changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cfd255e6-acf1-46c2-af9a-e5692fea2f3b
📒 Files selected for processing (7)
src/aap_eda/core/management/commands/create_initial_data.pysrc/aap_eda/settings/defaults.pytests/unit/commands/test_create_initial_data.pytools/docker/docker-compose-dev.yamltools/docker/docker-compose-mac.ymltools/docker/docker-compose-stage.yamltools/docker/postgres/initdb.d/create_event_persistence_db.sh
🚧 Files skipped from review as they are similar to previous changes (5)
- tools/docker/postgres/initdb.d/create_event_persistence_db.sh
- tools/docker/docker-compose-mac.yml
- tools/docker/docker-compose-stage.yaml
- src/aap_eda/settings/defaults.py
- src/aap_eda/core/management/commands/create_initial_data.py
e510dc3 to
5753b4e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
tools/docker/docker-compose-dev.yaml (1)
88-94:⚠️ Potential issue | 🟠 MajorPropagate event-persistence DB password into the Postgres bootstrap path
Line 88-Line 94 wires DB name/user, but the bootstrap flow still doesn’t carry a password into role creation. With a custom
EDA_EVENT_PERSISTENCE_DB_USER,tools/docker/postgres/initdb.d/create_event_persistence_db.shcreates a login role without a password, while the app connects usingEDA_EVENT_PERSISTENCE_DB_PASSWORD(Line 58). That can cause auth failures at runtime.Suggested compose-side adjustment
postgres: environment: POSTGRESQL_USER: eda POSTGRESQL_PASSWORD: secret POSTGRESQL_ADMIN_PASSWORD: secret POSTGRESQL_DATABASE: eda EDA_EVENT_PERSISTENCE_DB_NAME: ${EDA_EVENT_PERSISTENCE_DB_NAME:-eda_event_persistence} EDA_EVENT_PERSISTENCE_DB_USER: ${EDA_EVENT_PERSISTENCE_DB_USER:-eda} + EDA_EVENT_PERSISTENCE_DB_PASSWORD: ${EDA_EVENT_PERSISTENCE_DB_PASSWORD:-secret}Also update
tools/docker/postgres/initdb.d/create_event_persistence_db.shto applyEDA_EVENT_PERSISTENCE_DB_PASSWORDwhen creating/updating the role.As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/docker/docker-compose-dev.yaml` around lines 88 - 94, The compose service must export EDA_EVENT_PERSISTENCE_DB_PASSWORD into the Postgres container and the init script create_event_persistence_db.sh must consume that variable when creating/updating the DB role; add EDA_EVENT_PERSISTENCE_DB_PASSWORD to the service environment in the compose snippet (using ${EDA_EVENT_PERSISTENCE_DB_PASSWORD:-...}) and update create_event_persistence_db.sh to use that env var in the role creation/alteration command (e.g., CREATE ROLE/ALTER ROLE ... PASSWORD '...') so the persisted role has the same password the app expects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/aap_eda/core/management/commands/create_initial_data.py`:
- Around line 2514-2529: The validation block that builds the required dict when
EVENT_PERSISTENCE_DB_HOST is set is missing the database name; update the
required dictionary (the variable named required used in the create_initial_data
logic) to include "EVENT_PERSISTENCE_DB_NAME":
settings.EVENT_PERSISTENCE_DB_NAME (respecting the existing use_cert_auth
branch), so the subsequent missing = [k for k, v in required.items() if not v]
and the ImproperlyConfigured raise will also catch a missing DB name.
---
Duplicate comments:
In `@tools/docker/docker-compose-dev.yaml`:
- Around line 88-94: The compose service must export
EDA_EVENT_PERSISTENCE_DB_PASSWORD into the Postgres container and the init
script create_event_persistence_db.sh must consume that variable when
creating/updating the DB role; add EDA_EVENT_PERSISTENCE_DB_PASSWORD to the
service environment in the compose snippet (using
${EDA_EVENT_PERSISTENCE_DB_PASSWORD:-...}) and update
create_event_persistence_db.sh to use that env var in the role
creation/alteration command (e.g., CREATE ROLE/ALTER ROLE ... PASSWORD '...') so
the persisted role has the same password the app expects.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3bb354cd-8a5b-4d78-9c3f-26bf331c781e
📒 Files selected for processing (7)
src/aap_eda/core/management/commands/create_initial_data.pysrc/aap_eda/settings/defaults.pytests/unit/commands/test_create_initial_data.pytools/docker/docker-compose-dev.yamltools/docker/docker-compose-mac.ymltools/docker/docker-compose-stage.yamltools/docker/postgres/initdb.d/create_event_persistence_db.sh
✅ Files skipped from review due to trivial changes (2)
- tools/docker/postgres/initdb.d/create_event_persistence_db.sh
- src/aap_eda/settings/defaults.py
🚧 Files skipped from review as they are similar to previous changes (2)
- tools/docker/docker-compose-stage.yaml
- tools/docker/docker-compose-mac.yml
Adding rule engine system credential for event persistence. Update containerized deployment to support new database for the event persistence feature.
5753b4e to
1458112
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/commands/test_create_initial_data.py`:
- Around line 257-381: Tests for rule-engine credentials are flaky because they
rely on implicit EVENT_PERSISTENCE_* defaults; add a fixture (e.g.,
isolated_event_persistence_settings) that explicitly clears/resets all
EVENT_PERSISTENCE_DB_* and EVENT_PERSISTENCE_PGSSL* keys, use that fixture in
each rule-engine test
(test_create_initial_data_rule_engine_cred_not_created_without_host,
test_create_initial_data_rule_engine_cred_with_password_auth,
test_create_initial_data_rule_engine_cred_missing_required,
test_create_initial_data_rule_engine_cred_cert_auth,
test_create_initial_data_rule_engine_cred_with_rootcert), and keep per-test
override_settings(...) only for the scenario-specific values
(host/port/user/password/PGSSLCERT/PGSSLKEY/PGSSLROOTCERT) so each test runs
with deterministic event persistence settings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d9f84f88-6341-495b-bdd6-69be4c2db7fc
📒 Files selected for processing (7)
src/aap_eda/core/management/commands/create_initial_data.pysrc/aap_eda/settings/defaults.pytests/unit/commands/test_create_initial_data.pytools/docker/docker-compose-dev.yamltools/docker/docker-compose-mac.ymltools/docker/docker-compose-stage.yamltools/docker/postgres/initdb.d/create_event_persistence_db.sh
✅ Files skipped from review due to trivial changes (2)
- tools/docker/postgres/initdb.d/create_event_persistence_db.sh
- src/aap_eda/settings/defaults.py
🚧 Files skipped from review as they are similar to previous changes (4)
- tools/docker/docker-compose-dev.yaml
- src/aap_eda/core/management/commands/create_initial_data.py
- tools/docker/docker-compose-stage.yaml
- tools/docker/docker-compose-mac.yml
|
|
/run-e2e |



Adding rule engine system credential for event persistence. Update containerized deployment to support new database for the event persistence feature.
https://redhat.atlassian.net/browse/AAP-66375
Summary by CodeRabbit
New Features
Tests
Chores