Skip to content

Improve Jenkins db host network#5008

Merged
IvanIvanoff merged 1 commit intomasterfrom
improve-jenkins-db-host
Feb 18, 2026
Merged

Improve Jenkins db host network#5008
IvanIvanoff merged 1 commit intomasterfrom
improve-jenkins-db-host

Conversation

@IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented Feb 18, 2026

Changes

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

Chores

  • Enhanced test infrastructure with improved container orchestration and inter-service connectivity
  • Streamlined test resource cleanup and removal process for increased reliability
  • Added timeout protections for parallel test execution

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@IvanIvanoff has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The Jenkinsfile is refactored to replace hard-coded Docker container linking with Docker network-based connectivity for test Postgres instances. A dedicated test network is created at the start of tests, containers connect via this network, and comprehensive cleanup removes both containers and the network afterward.

Changes

Cohort / File(s) Summary
Docker Networking Refactor
Jenkinsfile
Introduces Docker network (test-net-${buildSuffix}) for Postgres containers, replacing link-based connectivity with network-based addressing. Updates DATABASE_URL to use network hostnames. Replaces docker kill loop with consolidated cleanup in finally block. Wraps parallel partition execution in timeout. Removes explicit container readiness wait block.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A network blooms where links once grew,
Postgres hops through channels new,
Docker's magic, clean and neat,
CI pipelines now complete! 🌐✨

🚥 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 'Improve Jenkins db host network' directly reflects the main change: refactoring the Jenkins Jenkinsfile to use Docker networking for database connectivity instead of hard-coded container linking.
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 improve-jenkins-db-host

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Jenkinsfile (1)

50-86: ⚠️ Potential issue | 🟠 Major

Resource leak if Postgres startup or readiness checks fail.

The network is created on line 50 and Postgres containers are started on lines 52–64, but the try/finally cleanup block doesn't begin until line 86. If anything between lines 52–84 fails (container start, readiness wait timeout), the finally on line 108 never runs, leaving orphaned containers and the Docker network behind.

Move the try to wrap everything from line 50 onward so the finally block always cleans up.

🔧 Proposed fix: Expand try/finally to cover all resource creation
-          sh "docker network create ${networkName}"
-
-          for (int i = 1; i <= numPartitions; i++) {
+          try {
+          sh "docker network create ${networkName}"
+
+          for (int i = 1; i <= numPartitions; i++) {
             ...
-          }
-
-          sh """
+          }
+
+          sh """
             ...  // readiness wait
-          """
-
-          try {
-            def partitions = [:]
+          """
+
+            def partitions = [:]
             ...
-            timeout(time: 25, unit: 'MINUTES') {
-              parallel partitions
-            }
+            timeout(time: 25, unit: 'MINUTES') {
+              parallel partitions
+            }
           } finally {
             sh """
               for i in \$(seq 1 ${numPartitions}); do
                 docker rm -f test-postgres-${buildSuffix}-p\$i 2>/dev/null || true
               done
               docker network rm ${networkName} 2>/dev/null || true
             """
           }

Also applies to: 108-114

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

In `@Jenkinsfile` around lines 50 - 86, The resource cleanup finally block doesn't
cover the Docker network and Postgres container creation/wait logic, so failures
between creating networkName and the readiness loop can leave orphaned
containers; move the existing try so it begins before the sh "docker network
create ${networkName}" and wraps the for-loop that creates postgresContainerName
and the subsequent readiness sh block (the code referencing numPartitions and
buildSuffix), ensuring the finally always executes to remove containers and the
network.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@Jenkinsfile`:
- Around line 50-86: The resource cleanup finally block doesn't cover the Docker
network and Postgres container creation/wait logic, so failures between creating
networkName and the readiness loop can leave orphaned containers; move the
existing try so it begins before the sh "docker network create ${networkName}"
and wraps the for-loop that creates postgresContainerName and the subsequent
readiness sh block (the code referencing numPartitions and buildSuffix),
ensuring the finally always executes to remove containers and the network.

@IvanIvanoff IvanIvanoff force-pushed the improve-jenkins-db-host branch from 3a132c0 to b976353 Compare February 18, 2026 13:08
@IvanIvanoff IvanIvanoff merged commit e23905f into master Feb 18, 2026
3 checks passed
@IvanIvanoff IvanIvanoff deleted the improve-jenkins-db-host branch February 18, 2026 13:15
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

Comments