Repository navigation
refactor: remove NApps directory observer (watchdog) feature - #638
Merged
Merged
Conversation
The NApps directory observer uses inotify, whose default instance limit (usually 128) is easily exhausted when running many kytos instances on the same host, causing kytosd to crash on startup. - Wrap the observer start in a try/except so a failure is logged (with traceback) and kytosd keeps running without it. - Add an ``enable_napps_observer`` setting (kytos.conf) and a ``-N``/``--enable_napps_observer`` CLI flag, disabled by default, to make the observer opt-in.
italovalcy
force-pushed
the
fix/issue-635
branch
from
September 16, 2026 16:06
d4da8b3 to
e77915f
Compare
quadflow
reviewed
Sep 17, 2026
Following review on PR #638, fully remove the watchdog-based NApps directory observer (NAppDirListener) instead of keeping it as an opt-in feature. The observer was half-baked (its path regex did not handle custom NApp paths) and could exhaust the system inotify instance limit when running many Kytos instances on the same host. The observer's only job was to load/unload a NApp when its enabled-dir symlink appeared/disappeared. Disabling already unloads directly, so make enabling load directly too (symmetric), and drop the observer entirely: - NAppsManager.enable now calls controller.load_napp after creating the symlink; the meta-NApp dependency loop no longer shadows the enabled NApp's name so a meta-NApp loads itself correctly. - Delete NAppDirListener and its wiring in Controller. - Remove the enable_napps_observer option (config, CLI flag, conf template) added earlier in this PR. - Drop the watchdog dependency from requirements.
quadflow
approved these changes
Sep 19, 2026
quadflow
left a comment
There was a problem hiding this comment.
Awesome how this turned out, thanks @italovalcy.
I also ran it locally with a custom napps path, I completely reinstalled the env from scratch, disabled/enabled napps, no unexpected side effects observed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #635
Summary
See updated changelog file.
The NApps directory observer (
NAppDirListener) relied onwatchdog/inotify to auto load/unload NApps when their enabled-directory symlink appeared or disappeared. Its default inotify instance limit (usually 128) is quickly exhausted when running heavy applications or many kytos instances in parallel on the same host, and when the limit is hit the observer fails to start andkytosdcrashes on startup (see the traceback below).This PR initially made the observer opt-in and fail-safe, but following review (thanks @quadflow) the approach was changed to fully remove the feature instead, since it was half-baked (its path regex assumed
kytos/nappsis always part of the path and did not handle custom NApp paths), an opt-in toggle would be confusing to document, and removing it lets us drop thewatchdogdependency.The observer's only job was to load/unload a NApp when its enabled-dir symlink changed. Disabling a NApp already calls
unload_nappdirectly, so this PR makes enabling symmetric —NAppsManager.enablenow callsload_nappdirectly after creating the symlink (the meta-NApp dependency loop was fixed to no longer shadow the enabled NApp's name, so a meta-NApp loads itself correctly) — and then removes the observer entirely:NAppDirListenerand its wiring inController(start/stop).enable_napps_observerconfig option /-N/--enable_napps_observerCLI flag / conf template entry that were added earlier in this PR.watchdogdependency fromrequirements/.The original problem
In a docker container with a single Kytos instance, the crash can be reproduced by lowering the inotify limit:
With this PR the observer (and the
watchdogdependency) no longer exists, so this failure path is gone entirely, and enabling/disabling a NApp loads/unloads it directly.Local Tests
Ran locally.
tests/unit/test_core/test_napp_dir_listener.py(feature removed) and the observer-specific controller tests.tests/unit/test_core/test_napps_manager.py::test_enablenow asserts the NApp is loaded viacontroller.load_nappafter being enabled.tests/unitsuite passing.End-to-End Tests
Not needed for this case; there are no e2e tests covering the NApps observer. Enabling/disabling NApps through the existing REST endpoints continues to load/unload them.