Skip to content

Fix multifaucet DB exec in CI by replacing docker_container_exec with…#736

Open
vivekgsharma wants to merge 9 commits intov1.0-devfrom
vivek/devent-ci-testing
Open

Fix multifaucet DB exec in CI by replacing docker_container_exec with…#736
vivekgsharma wants to merge 9 commits intov1.0-devfrom
vivek/devent-ci-testing

Conversation

@vivekgsharma
Copy link
Collaborator

@vivekgsharma vivekgsharma commented Mar 5, 2026

Testting Devnet creationg autmation using CI

Summary by CodeRabbit

  • Refactor
    • Updated deployment configuration to improve database availability checks with enhanced validation and retry handling.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Ansible task file refactored to replace docker_container_exec module calls with direct ansible.builtin.shell invocations using docker exec commands. Database availability check enhanced with retry count increase and dual-condition validation. All SQL execution tasks migrated to shell-based docker exec with inline statements.

Changes

Cohort / File(s) Summary
Docker Execution Migration
ansible/roles/multifaucet/tasks/main.yml
Replaced docker_container_exec module with ansible.builtin.shell executing docker exec commands. Updated "Wait for database" task with multiline shell and enhanced condition checking (rc == 0 and stdout content); increased retries from 10 to 30. Migrated all SQL execution tasks ("Create promo codes table", "Load MN/HPMN/platform promo code") to inline shell-based docker exec with -e SQL statements while preserving control-flow conditions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰✨ A rabbit's ode to the refactor

Docker containers, once called by name,
Now dance through the shell, just the same,
Retries grew from ten to thirty bright,
SQL statements inline, executed right,
The warren rejoices—efficiency takes flight! 🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing docker_container_exec with docker exec for multifaucet DB execution in CI, which directly corresponds to the changeset modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vivek/devent-ci-testing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
ansible/roles/multifaucet/tasks/main.yml (1)

47-50: Consider adding changed_when: false for idempotent SQL tasks.

The CREATE TABLE IF NOT EXISTS SQL is idempotent, but without changed_when: false, Ansible will report the task as "changed" on every run. This applies to the subsequent INSERT IGNORE tasks as well.

♻️ Proposed fix
 - name: Create promo codes table
   ansible.builtin.shell: |
     docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
       -e 'CREATE TABLE IF NOT EXISTS faucet_promo_codes (id int NOT NULL, code varchar(255), minimum_payout int, maximum_payout int, PRIMARY KEY (id));'
+  changed_when: false
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ansible/roles/multifaucet/tasks/main.yml` around lines 47 - 50, The SQL tasks
(e.g., the "Create promo codes table" task that runs the 'CREATE TABLE IF NOT
EXISTS faucet_promo_codes' command and the follow-up tasks that run 'INSERT
IGNORE') are idempotent but will always report changed; update these tasks to
include changed_when: false so Ansible does not mark them as changed on every
run. Locate the task named "Create promo codes table" and other tasks executing
INSERT IGNORE against faucet_promo_codes and add changed_when: false to each
task definition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ansible/roles/multifaucet/tasks/main.yml`:
- Around line 52-55: The "Load MN promo code" ansible task's single-line SQL
exceeds the 160-char limit; split the SQL string across multiple lines inside
the ansible.builtin.shell block so no line is longer than 160 chars. Edit the
task named "Load MN promo code" and replace the long -e 'INSERT ...' single line
with a multiline SQL (preserve the docker exec ... -e '<SQL>' structure), e.g.
put the INSERT clause, the VALUES clause, and each value on separate lines while
keeping the masternode_collaterals.mn and {{ masternode_collaterals.mn | int +
10 }} variables intact and correctly quoted/templated so YAML indentation and
shell quoting remain valid.
- Around line 57-61: The shell task "Load HPMN promo code" contains a single
long -e SQL string that exceeds the 160-char limit; split the SQL argument
across multiple lines inside the existing ansible.builtin.shell block so no
single source line is >160 chars, keeping the docker exec invocation and Jinja
vars (masternode_collaterals.hpmn) intact and preserving proper quoting/escaping
for the -e argument and the INSERT IGNORE statement.

---

Nitpick comments:
In `@ansible/roles/multifaucet/tasks/main.yml`:
- Around line 47-50: The SQL tasks (e.g., the "Create promo codes table" task
that runs the 'CREATE TABLE IF NOT EXISTS faucet_promo_codes' command and the
follow-up tasks that run 'INSERT IGNORE') are idempotent but will always report
changed; update these tasks to include changed_when: false so Ansible does not
mark them as changed on every run. Locate the task named "Create promo codes
table" and other tasks executing INSERT IGNORE against faucet_promo_codes and
add changed_when: false to each task definition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4aca3fd-09f1-4b2b-8737-be9d111ea648

📥 Commits

Reviewing files that changed from the base of the PR and between e456676 and 2619eb6.

📒 Files selected for processing (1)
  • ansible/roles/multifaucet/tasks/main.yml

Comment on lines 52 to +55
- name: Load MN promo code
community.docker.docker_container_exec:
container: multifaucet-db-1
command: >
mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet"
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout)
VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
ansible.builtin.shell: |
docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix line length to resolve pipeline failure.

Line 55 exceeds the 160-character limit (188 characters), causing the CI pipeline to fail. Break the SQL statement across multiple lines.

🔧 Proposed fix
 - name: Load MN promo code
   ansible.builtin.shell: |
     docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
-      -e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
+      -e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) \
+          VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
+  changed_when: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Load MN promo code
community.docker.docker_container_exec:
container: multifaucet-db-1
command: >
mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet"
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout)
VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
ansible.builtin.shell: |
docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
- name: Load MN promo code
ansible.builtin.shell: |
docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) \
VALUES (1,"masternode",{{ masternode_collaterals.mn }},{{ masternode_collaterals.mn | int + 10 }});'
changed_when: false
🧰 Tools
🪛 GitHub Actions: Package Tests

[error] 55-55: yaml line-length: Line too long (188 > 160 characters)

🪛 GitHub Check: Test package

[failure] 55-55: yaml[line-length]
Line too long (188 > 160 characters)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ansible/roles/multifaucet/tasks/main.yml` around lines 52 - 55, The "Load MN
promo code" ansible task's single-line SQL exceeds the 160-char limit; split the
SQL string across multiple lines inside the ansible.builtin.shell block so no
line is longer than 160 chars. Edit the task named "Load MN promo code" and
replace the long -e 'INSERT ...' single line with a multiline SQL (preserve the
docker exec ... -e '<SQL>' structure), e.g. put the INSERT clause, the VALUES
clause, and each value on separate lines while keeping the
masternode_collaterals.mn and {{ masternode_collaterals.mn | int + 10 }}
variables intact and correctly quoted/templated so YAML indentation and shell
quoting remain valid.

Comment on lines 57 to 61
- name: Load HPMN promo code
community.docker.docker_container_exec:
container: multifaucet-db-1
command: >
mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet"
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout)
VALUES (2,"hp-masternode",{{ masternode_collaterals.hpmn }},{{ masternode_collaterals.hpmn | int + 10 }});'
ansible.builtin.shell: |
docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
-e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) VALUES (2,"hp-masternode",{{ masternode_collaterals.hpmn }},{{ masternode_collaterals.hpmn | int + 10 }});'
when: dash_network == "devnet"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix line length to resolve pipeline failure.

Line 60 exceeds the 160-character limit (195 characters), causing the CI pipeline to fail. Break the SQL statement across multiple lines.

🔧 Proposed fix
 - name: Load HPMN promo code
   ansible.builtin.shell: |
     docker exec multifaucet-db-1 mysql -h localhost -D multifaucet -u multifaucet --password="multifaucet" \
-      -e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) VALUES (2,"hp-masternode",{{ masternode_collaterals.hpmn }},{{ masternode_collaterals.hpmn | int + 10 }});'
+      -e 'INSERT IGNORE INTO faucet_promo_codes (id,code,minimum_payout,maximum_payout) \
+          VALUES (2,"hp-masternode",{{ masternode_collaterals.hpmn }},{{ masternode_collaterals.hpmn | int + 10 }});'
+  changed_when: false
   when: dash_network == "devnet"
🧰 Tools
🪛 GitHub Actions: Package Tests

[error] 60-60: yaml line-length: Line too long (195 > 160 characters)

🪛 GitHub Check: Test package

[failure] 60-60: yaml[line-length]
Line too long (195 > 160 characters)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ansible/roles/multifaucet/tasks/main.yml` around lines 57 - 61, The shell
task "Load HPMN promo code" contains a single long -e SQL string that exceeds
the 160-char limit; split the SQL argument across multiple lines inside the
existing ansible.builtin.shell block so no single source line is >160 chars,
keeping the docker exec invocation and Jinja vars (masternode_collaterals.hpmn)
intact and preserving proper quoting/escaping for the -e argument and the INSERT
IGNORE statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant