Skip to content
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

Merged
merged 4 commits into from
Sep 20, 2024

Conversation

nemacysts
Copy link
Member

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

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
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:")
Copy link
Member Author

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"
Copy link
Member Author

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)
Copy link
Member Author

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

Copy link
Contributor

@jfongatyelp jfongatyelp left a 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!

@nemacysts nemacysts merged commit 6c78e90 into master Sep 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants