[bug] SSH connection leaked when update_config() raises an exception
メンテナーはふだん 1 日以内に返信
@tomsebastian10 がすでに取り組んでいます。
2026年3月21日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- backend, networking
調査の方向性
openwisp_controller/connection/base/models.py の365–373行付近から始め、DeviceConnection.update_config() のフローを確認します。設定のプッシュに失敗するケースを再現し、その後、正常終了時と例外終了時の両方で SSH 接続が切断され、ファイルディスクリプタが開いたまま残らないことを確認します。
索引モデルが issue の本文から書いたものです。
説明
● Describe the bug
In DeviceConnection.update_config(), the SSH connection is only closed
in the else block, which means it is never disconnected when an
exception occurs during a config push. Over time this leaks SSH file
descriptors and can crash the controller process with:
OSError: [Errno 24] Too many open files
● Steps To Reproduce
- Set up a device with an SSH
DeviceConnection - Make the config push fail intentionally (e.g. wrong credentials, unreachable device, or network drop mid-transfer)
- Observe that no
disconnect()is called — the SSH session stays open - Repeat for multiple devices; file descriptor count keeps growing
● Root cause (file + line)
File: openwisp_controller/connection/base/models.py
Lines: 365–373
def update_config(self):
self.connect()
if self.is_working:
try:
self.connector_instance.update_config()
except Exception as e:
logger.exception(e)
else:
self.disconnect() # ← only runs when NO exception is raised
The else block in a try/except/else only executes when the try
block completes without raising. Any exception causes disconnect()
to be skipped entirely.
● Expected behavior
The SSH connection should always be closed after update_config()
completes — whether it succeeded or failed — to prevent file descriptor
leaks on production controllers.
● Proposed fix
Change else to finally:
def update_config(self):
self.connect()
if self.is_working:
try:
self.connector_instance.update_config()
except Exception as e:
logger.exception(e)
finally:
self.disconnect() # ← runs always, success OR failure
● Screenshots
Not applicable (code-level bug).
● System Information
- OS: Ubuntu 24.04 LTS
- Python Version: Python 3.10+
- Django Version: Django 4.2+
- Browser and Browser Version (if applicable): Not applicable
- 主要言語
- Python
- スター
- 779
- フォーク
- 328
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openwisp/openwisp-controller のほかの issue
-
[fix] Recent Commands row uses "created" timestamp for the "Modified" field対応中かも @xovishnukosuri が 216 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
openwisp/openwisp-controller#1263 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
[feature] Emit a signal when a device operating system changes対応中かも @Vara715 が今日担当しました。 オープンenhancement
難易度 3/5 半日 初心者へのやさしさ 65/100
openwisp/openwisp-controller#1506 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
[feature] Add board_name field to Device model for DTB board identification再び着手できるかも @atif09 が 28 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement gsoc
openwisp/openwisp-controller#1491 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[bug:gsoc26] Mass command wizards started in two browser tabs overwrite each other対応中かも @dee077 が 31 日前に担当しました。 オープンbug
openwisp/openwisp-controller#1489 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
openwisp/openwisp-controller#1484 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
openwisp/openwisp-controller の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
EchoTools/nevr-runtime#651 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend rt sev-3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
noontide-co/mainbranch#1211 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[1.x Bug] run-operation --sql reports success but rolls back writes on transaction-capable adaptersオープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
dbt-labs/dbt#16784 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信