Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/operator/backend_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ def calculate_pod_status(pod: Any) -> Tuple[task.TaskGroupStatus, str, Optional[
# When a container fails to create, the pod will not be Ready.
# The lastTransitionTime of this condition is the closest timestamp.
if condition.type == 'Ready' and condition.status == 'False':
now = datetime.datetime.now()
now = datetime.datetime.now(datetime.timezone.utc)
last_transition_time = condition.last_transition_time
if last_transition_time:
time_diff = now - last_transition_time
Expand Down
11 changes: 6 additions & 5 deletions src/operator/tests/test_pod_status_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@


def parse_time_string(time_str: str) -> datetime.datetime:
"""Parse time strings like 'now', 'now-5m', 'now-15m' into datetime objects"""
"""Parse time strings like 'now', 'now-5m', 'now-15m' into timezone-aware UTC datetimes."""
utc_now = datetime.datetime.now(datetime.timezone.utc)
if time_str == 'now':
return datetime.datetime.now()
return utc_now
elif time_str.startswith('now-'):
parts = time_str[4:]
if parts.endswith('m'):
minutes = int(parts[:-1])
return datetime.datetime.now() - datetime.timedelta(minutes=minutes)
return utc_now - datetime.timedelta(minutes=minutes)
elif parts.endswith('h'):
hours = int(parts[:-1])
return datetime.datetime.now() - datetime.timedelta(hours=hours)
return datetime.datetime.now()
return utc_now - datetime.timedelta(hours=hours)
return utc_now


def create_pod_from_json(test_input: Dict) -> V1Pod:
Expand Down
Loading