fix(plugins): resolve plugin paths using directory tree - #1424
Conversation
Possible breaking changesThis fix changes how plugins are discovered and resolved. Most existing checks should keep working, but some may need updates. Duplicate filenames (most likely impact)Previously, if the same filename existed in the plugins root and a subdirectory (e.g. plugins/check_disk.sh and plugins/old/check_disk.sh), NCPA kept only one entry and the subdirectory copy could overwrite the root copy. A request to plugins/check_disk.sh might have been running the subdirectory version. After this change: plugins/check_disk.sh always runs the root-level file Action required: If a check was intentionally using the subdirectory copy while calling plugins/ (without the subdirectory path), update it to the full relative path, e.g. plugins/old/check_disk.sh. Checks that target a root-level plugin and have no duplicate filename elsewhere are unaffected. Checks using subdirectory pluginsIf you were running a plugin that lives in a subdirectory (e.g. plugins/old/check_disk.sh) by calling it without the subdirectory path — for example:
With this fix, plugins/check_disk.sh always runs the root-level file. To run the subdirectory copy, update the check to include the full relative path:
Plugin inventory APIGET /api/plugins now lists subdirectory plugins with their relative path (e.g. old/check_disk.sh), not only root-level basenames. Anything that parses this response and assumes every entry is a root-level filename may need to be updated. What does not require changesChecks using plugins/ for a plugin that exists only at the root level |
Summary
plugins/get_script_dir.ps1vsplugins/old/get_script_dir.ps1). Closes NCPA resolves wrong plugin file when duplicate filename exists in a subdirectory #1423. Closes Plugins folder - files in subdirectories have higher precedence #1257plugins/old/check_disk.sh) and lists them in the plugin inventory. Closes multiple plugin_path #811.Test plan
python -m unittest test_pluginnodes -vfrom thetest/directoryget_script_dir.ps1(or.shon Linux) in the plugins root and confirmcheck_ncpa.py -M 'plugins/get_script_dir.ps1'reports the root directoryplugins/old/and confirm the same command still runs the root copyplugins/old/get_script_dir.ps1runs the subdirectory copy when requested explicitly/api/pluginslists both root and subdirectory plugins with relative paths