Bug Description
When a new .py file is added to a git-based custom playbook repository and a config reload is triggered (via FileSystemWatcher detecting changes to the playbooks config or playbooks directory), the new module is not discovered by pkgutil.walk_packages(). The new action only becomes available after a full pod restart.
Changes to existing files work fine — importlib.reload() picks them up. Only newly added files are affected.
Root Cause
In ConfigLoader.__import_playbooks_package() (src/robusta/runner/config_loader.py), after pip install copies new files to site-packages, pkgutil.walk_packages() relies on Python's FileFinder to enumerate modules. The FileFinder caches directory listings from the initial import at process startup. Since importlib.invalidate_caches() is never called, newly installed .py files remain invisible to the finder machinery.
From the Python docs:
If you are dynamically importing a module that was created since the interpreter began execution (e.g., created a Python source file), you may need to call this function in order to notice the new module.
Steps to Reproduce
- Configure a git-based custom playbook repo in Robusta
- Let the runner start and load the initial set of actions
- Add a new
.py file with a new action to the git repo and push
- Trigger a config reload (e.g., update the
robusta-playbooks-config-secret)
- Observe that the new action is not registered — only existing actions are reloaded
- Restart the pod — the new action is now available
Expected Behavior
New playbook modules added to git repos should be discovered and loaded during hot reload without requiring a pod restart.
Proposed Fix
Add importlib.invalidate_caches() before the pkgutil.walk_packages() call in __import_playbooks_package().
Bug Description
When a new
.pyfile is added to a git-based custom playbook repository and a config reload is triggered (viaFileSystemWatcherdetecting changes to the playbooks config or playbooks directory), the new module is not discovered bypkgutil.walk_packages(). The new action only becomes available after a full pod restart.Changes to existing files work fine —
importlib.reload()picks them up. Only newly added files are affected.Root Cause
In
ConfigLoader.__import_playbooks_package()(src/robusta/runner/config_loader.py), afterpip installcopies new files to site-packages,pkgutil.walk_packages()relies on Python'sFileFinderto enumerate modules. TheFileFindercaches directory listings from the initial import at process startup. Sinceimportlib.invalidate_caches()is never called, newly installed.pyfiles remain invisible to the finder machinery.From the Python docs:
Steps to Reproduce
.pyfile with a new action to the git repo and pushrobusta-playbooks-config-secret)Expected Behavior
New playbook modules added to git repos should be discovered and loaded during hot reload without requiring a pod restart.
Proposed Fix
Add
importlib.invalidate_caches()before thepkgutil.walk_packages()call in__import_playbooks_package().