Repository navigation
Conversation
…ion_fail_reporting
…ion_fail_reporting
| console_log=True, | ||
| ) | ||
| self.connection = None | ||
| self.result.status = ExecutionStatus.EXECUTION_FAILURE |
There was a problem hiding this comment.
i think we should also set self.result.message here otherwise it will be empty for a failed SSH or Refish connection
There was a problem hiding this comment.
I have added a section which includes message + event description instead of only the event descriptions
| @@ -244,12 +263,10 @@ def discover_os_info(self) -> None: | |||
| discover_and_write_os_family(inband_connection, self.system_info, self.logger) | |||
| except Exception as e: | |||
| self.logger.error( | |||
| "Error occurred during OS discovery with InBandConnectionManager: %s", | |||
| str(e), | |||
| "Error occurred during OS discovery with InBandConnectionManager: %s", str(e) | |||
There was a problem hiding this comment.
there might be another issue here: result.status is not set to OK its left as UNSET in the decorator here: nodescraper/interfaces/connectionmanager.py when shell is successful and SSH returns, so maybe we need to fix that first. Then we need to update this code and let this: discover_and_write_os_family(inband_connection, self.system_info, self.logger) run after a successful connection
There was a problem hiding this comment.
Most connection managers do not set a status or a message however since we have the connect_decorator it will always either get an exception resulting in log_event call and the result being set to EXECUTION_FAILURE here
connection_manager.result.status = ExecutionStatus.EXECUTION_FAILURE
connection_manager.result.message = f"Connection failed: {str(exception)}"However, if there is a connection pass then the connect_decorator will eventually call result.finalize() which will reach _update_status() here, this will then use the event's here to determine what self.status should be, if there are ERROR or CRITICAL events the status is ERROR and if there are WARNING events then the status is WARNING, otherwise the status is set to OK.
So if connect is called it will always cause a result of one of
NOT_RAN
OK
WARNING
ERROR
EXECUTION_FAILURE
…e-scraper into bugfix/connection_fail_reporting
Summary
ConnectionManager._fail_connect()records one CRITICAL event, clears the connection and setsEXECUTION_FAILURE.connect_decoratoris the backstop: an unexpected exception, or a result that is stillUNSETwith no connection, becomes a failure with a CRITICAL event, so no failed connection is silent.<plugin>/<collector>/connection/DataPluginResult.connection_result, a snapshot of the connection result for the plugin run, and put connection result inDataPluginResultERRORorEXECUTION_FAILUREis not reconnected by later plugins. A manager that isUNSET,OKorWARNINGwith no live connection (for example after a disconnect) is still reconnected.disconnect()keeps the connection result instead of resetting it toUNSET. Addsafe_disconnect(), which logs instead of raising, so one failing disconnect cannot stop the rest from closing.preserve_connectionnow defaults toTrueonDataPlugin.collect()/run(). A manager the plugin created is always closed; a manager passed in by the caller stays open unlesspreserve_connection=False. The executor no longer force-sets it.FileSystemLogHookno longer overwrites earlier logs. The first result in a directory goes toresult.json/events.json, later ones toresult(1).json/events(1).json, and so on. The data-model file is not numbered._close_connections()are split out ofrun_queue, and connections are always closed even if a post-action or collator raises._fail_connect(), so each failed target produces an event.TypeUtils.filter_to_model_fields()to replace three copies of the global-arg filtering.Result format example
OsPluginagainst a remote host over SSH, all steps successful (scraper_logs_....)Typical result
{ "status": "OK", "message": "task completed successfully", "task": "InBandConnectionManager", "parent": "os_discovery", "details": {}, "start_time": "2026-10-27T07:21:44.196857", "end_time": "2026-10-27T07:21:45.691677" }Console Log result
On a failed connection, the same
result.jsonis written with"status": "EXECUTION_FAILURE"and the reason inmessage, next to anevents.jsonholding the CRITICAL event. Dependent plugins reportNOT_RANand do not reconnect.Failed Example:
The failed example will have a result like below found in a folder like
~/node-scraper/scraper_logs_2026_10_27-08_12_41_AM/os_plugin/in_band_connection_manager/events.json[ { "id": "2258a79e-abc9-4e0b-a8eb-de24b79dec06", "timestamp": "2026-10-27T15:12:42.071014Z", "reporter": "NODE_SCRAPER", "category": "SSH", "description": "SSH connection to 'system-name-lab-123-56' failed: SSH network error: [Errno 21] Is a directory: '/home/notadir'", "data": { "task_name": "InBandConnectionManager", "task_type": "CONNECTION_MANAGER", "parent": "OsPlugin", "session_id": "676dc412-bda8-4a62-be6e-bd6b18258057" }, "priority": "CRITICAL" } ]Behaviour changes
preserve_connectiondefaults toTrue. External callers that passconnection_manager=and relied on it being closed afterrun()must close it themselves or passpreserve_connection=False.events.json.ConnectionManager.disconnect()no longer resets the result toUNSET.Test plan
pytest test/unitpytest test/functional(if applicable)pre-commit run --all-filesChecklist