ssulav commented on code in PR #9247:
URL: https://github.com/apache/ozone/pull/9247#discussion_r2675999227
##########
tools/installer/callback_plugins/last_failed.py:
##########
@@ -0,0 +1,57 @@
+from __future__ import annotations
+
+import os
+from pathlib import Path
+from ansible.plugins.callback import CallbackBase
+
+
+class CallbackModule(CallbackBase):
+ CALLBACK_VERSION = 2.0
+ CALLBACK_TYPE = 'notification'
+ CALLBACK_NAME = 'last_failed'
+ CALLBACK_NEEDS_WHITELIST = False
+
+ def __init__(self):
+ super().__init__()
+ # Write to installer logs dir
+ self._out_dir = Path(__file__).resolve().parents[1] / "logs"
+ self._out_file = self._out_dir / "last_failed_task.txt"
+ try:
+ os.makedirs(self._out_dir, exist_ok=True)
+ except Exception:
+ pass
+
+ def _write_last_failed(self, result):
+ try:
+ task_name = result._task.get_name() # noqa
+ task_path = getattr(result._task, "get_path", lambda: None)() #
noqa
+ lineno = getattr(result._task, "get_lineno", lambda: None)() #
noqa
+ role_name = None
+ if task_path and "/roles/" in task_path:
+ try:
+ role_segment = task_path.split("/roles/")[1]
+ role_name = role_segment.split("/")[0]
+ except Exception:
+ role_name = None
+ host = getattr(result, "_host", None)
+ host_name = getattr(host, "name", "unknown") if host else "unknown"
+ line = f"{task_name}\n# host: {host_name}\n"
+ if task_path:
+ line += f"# file: {task_path}\n"
+ if lineno:
+ line += f"# line: {lineno}\n"
+ if role_name:
+ line += f"# role: {role_name}\n"
+ with open(self._out_file, "w", encoding="utf-8") as f:
Review Comment:
@yandrey321 - Can we add state machine in a later commit. As we need to work
on other major improvments, like adding kerberos auth, tls, upgrade etc.
If that sounds ok, I will add ToDo for better capture of state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]