Skip to content

Close DB connections once forked processes have completed#471

Merged
smk4664 merged 4 commits intodevelopfrom
NAPPS-770-develop/nornir-db-connections
Jan 8, 2026
Merged

Close DB connections once forked processes have completed#471
smk4664 merged 4 commits intodevelopfrom
NAPPS-770-develop/nornir-db-connections

Conversation

@smk4664
Copy link
Copy Markdown
Contributor

@smk4664 smk4664 commented Dec 23, 2025

Closes: #366

What's Changed

When running the SSOTSyncNetworkData job with 10 devices, the DB connection count would increment by 20, which meant there were two places the code was forking. The first was with the Nornir calling netmiko_send_commands, and the second was with the CommandGetterProcessor in the Nornir setup. Wrapping both of these with the connections.close_call() would close those 20 db connections (10 in one and 10 in the other) after they were finished without breaking the job.

This resolves the issue for both Jobs, as they use the same underlying netmiko_send_commands and CommandGetterProcessor.

To Do

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

@github-actions
Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  nautobot_device_onboarding/nornir_plays
  command_getter.py
  processor.py
  nautobot_device_onboarding/utils
  helper.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Copy Markdown
Contributor

@gsnider2195 gsnider2195 left a comment

Choose a reason for hiding this comment

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

This is working great for me. Thanks @smk4664!
It would be nice to have a small blurb in the docs to explain how to use the fakenos compose file

Comment thread development/Dockerfile-fakenos Outdated
Comment thread development/Dockerfile-fakenos Outdated
smk4664 and others added 3 commits December 29, 2025 20:17
Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com>
Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com>
@smk4664 smk4664 merged commit 209bcbb into develop Jan 8, 2026
14 checks passed
@smk4664 smk4664 deleted the NAPPS-770-develop/nornir-db-connections branch January 8, 2026 16:14
latuannetnam pushed a commit to latuannetnam/nautobot-app-device-onboarding that referenced this pull request Jan 9, 2026
* Fix issue with DB connections not closing

* Update development/Dockerfile-fakenos

Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com>

* Update development/Dockerfile-fakenos

Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com>

* Add fakenos documentation

---------

Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com>
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.

device onboarding not releasing completed job connections to postgresql db

4 participants