-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always use datetime.now(timezone.utc) in paasta status #3963
Conversation
This will make it clear that we're always using UTC internally and avoids the footgun of using utcnow() I've verified that the output for warming up pods is still the same in both this version of the code as well as in status quo - as well as the same for flink and kafka workloads
8bf156a
to
629e89b
Compare
This is probably better than the previous output where it was unclear what offset the times were in without looking at the parenthentical humanized time
@@ -730,7 +733,7 @@ def get_pod_uptime(pod_deployed_timestamp: str): | |||
|
|||
|
|||
def append_pod_status(pod_status, output: List[str]): | |||
output.append(f" Pods:") | |||
output.append(" Pods:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can revert these f-string changes - but i noticed that these didn't need to be f-strings while tracing the impact of my changes
@@ -1825,7 +1832,7 @@ def print_kafka_status( | |||
desired_state = annotations.get(paasta_prefixed("desired_state")) | |||
if desired_state is None: | |||
raise ValueError( | |||
f"expected desired state in kafka annotation, but received none" | |||
"expected desired state in kafka annotation, but received none" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above: i can revert these f-string changes - but i noticed that these didn't need to be f-strings while tracing the impact of my changes
start_time = datetime.strptime( | ||
broker["deployed_timestamp"], "%Y-%m-%dT%H:%M:%SZ" | ||
) | ||
delta = datetime.utcnow() - start_time | ||
).replace(tzinfo=timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will add a +00:00 to broker started times - e.g., we'll go from
Started
2024-09-18 01:11:36 (20 hours ago)
to
Started
2024-09-18 01:11:36+00:00 (20 hours ago)
but imo, this is a net positive since without looking at the parenthetical, it's entirely unclear what TZ is being used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty for all the breadcrumbs for future us so we don't make the same mistake again!
This will make it clear that we're always using UTC internally and avoids the footgun of using utcnow()
I've verified that the output for warming up pods is still the same in both this version of the code as well as in status quo - as well as the same for flink and kafka workloads
NOTE: there's still usages of utcnow or now() without an explicit timezone - but that's for another day