From 27938cbac2a6e1c30aa88878e0d24e4245848f61 Mon Sep 17 00:00:00 2001 From: Eman Elsabban Date: Fri, 17 Jan 2025 10:46:04 -0800 Subject: [PATCH] Adding comments --- tron/core/action.py | 7 +++++++ tron/core/actionrun.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/tron/core/action.py b/tron/core/action.py index efe4a5d83..33b18c355 100644 --- a/tron/core/action.py +++ b/tron/core/action.py @@ -115,6 +115,13 @@ def serialize_namedtuple(obj): return obj try: + # NOTE: you'll notice that there's a lot of get() accesses of state_data for + # pretty common fields - this is because ActionCommandConfig is used by more + # than one type of ActionRun (Kubernetes, Mesos, SSH) and these generally look + # different. Alternatively, some of these fields are used by KubernetesActionRun + # but are relatively new and older runs do not have data for them. + # Once we get rid of the SSH and Mesos code as well as older runs in DynamoDB, + # we'll likely be able to clean this up. return json.dumps( { "command": state_data["command"], diff --git a/tron/core/actionrun.py b/tron/core/actionrun.py index 5f067e251..efec9bcdf 100644 --- a/tron/core/actionrun.py +++ b/tron/core/actionrun.py @@ -185,6 +185,11 @@ def to_json(state_data: dict) -> Optional[str]: "end_time": state_data["end_time"].isoformat() if state_data["end_time"] else None, "rendered_command": state_data["rendered_command"], "exit_status": state_data["exit_status"], + # NOTE: mesos_task_id can be deleted once we delete all Mesos + # code and run data - and kubernetes_task_id can then be + # accessed unconditionally :) + # (see note in ActionCommandConfig::to_json() for more + # information about why we do this) "mesos_task_id": state_data.get("mesos_task_id"), "kubernetes_task_id": state_data.get("kubernetes_task_id"), }