Skip to content

teuthology-node-cleanup: use same timezone as local - #2079

Open
kshtsk wants to merge 1 commit into
ceph:mainfrom
kshtsk:wip-respect-local-tz
Open

teuthology-node-cleanup: use same timezone as local#2079
kshtsk wants to merge 1 commit into
ceph:mainfrom
kshtsk:wip-respect-local-tz

Conversation

@kshtsk

@kshtsk kshtsk commented Aug 28, 2025

Copy link
Copy Markdown
Contributor

@kshtsk
kshtsk requested a review from a team as a code owner August 28, 2025 15:06
@kshtsk
kshtsk requested review from VallariAg and amathuria and removed request for a team August 28, 2025 15:06
@kshtsk
kshtsk force-pushed the wip-respect-local-tz branch from 0aff8fb to 4ab4197 Compare August 28, 2025 15:07
@kshtsk
kshtsk requested a review from zmc September 2, 2025 15:25
@kshtsk
kshtsk force-pushed the wip-respect-local-tz branch from 4ab4197 to 0b8b93e Compare September 3, 2025 17:04
Fixes: https://tracker.ceph.com/issues/72773

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
@kshtsk
kshtsk force-pushed the wip-respect-local-tz branch from 6930aeb to 5a72896 Compare September 9, 2025 19:34

@zmc zmc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main:

>>> now = datetime.datetime.now(datetime.timezone.utc)
>>> now
datetime.datetime(2025, 12, 3, 18, 40, 4, 927253, tzinfo=datetime.timezone.utc)
>>> tzhere = now.astimezone().tzinfo
>>> job_updated = '2025-12-03 18:00:00'
>>> delta = now - parse_timestamp(job_updated)
>>> delta.total_seconds() / 3600
0.6680353480555555

With these changes:

>>> now = datetime.datetime.now(datetime.timezone.utc)
>>> now
datetime.datetime(2025, 12, 3, 18, 39, 28, 578278, tzinfo=datetime.timezone.utc)
>>> tzhere = now.astimezone().tzinfo
>>> job_updated = '2025-12-03 18:00:00'
>>> delta = now - parse_timestamp(job_updated, tzhere)
>>> delta.total_seconds() / 3600
-6.3420615894444445

This would cause significant problems in sepia (where everything is UTC). I suggest we do all calculations using UTC.

@kshtsk

kshtsk commented Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

On main:

>>> now = datetime.datetime.now(datetime.timezone.utc)
>>> now
datetime.datetime(2025, 12, 3, 18, 40, 4, 927253, tzinfo=datetime.timezone.utc)
>>> tzhere = now.astimezone().tzinfo
>>> job_updated = '2025-12-03 18:00:00'
>>> delta = now - parse_timestamp(job_updated)
>>> delta.total_seconds() / 3600
0.6680353480555555

With these changes:

>>> now = datetime.datetime.now(datetime.timezone.utc)
>>> now
datetime.datetime(2025, 12, 3, 18, 39, 28, 578278, tzinfo=datetime.timezone.utc)
>>> tzhere = now.astimezone().tzinfo
>>> job_updated = '2025-12-03 18:00:00'
>>> delta = now - parse_timestamp(job_updated, tzhere)
>>> delta.total_seconds() / 3600
-6.3420615894444445

This would cause significant problems in sepia (where everything is UTC). I suggest we do all calculations using UTC.

I guess you're doing it on your laptop, which is in East Pacific?

Here what I have running on UTC, teuthology.front:

(virtualenv) kyr@teuthology:~/teuthology$ python3
Python 3.10.17 (main, Apr  9 2025, 08:54:15) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> from teuthology.util.time import parse_timestamp
>>> job_updated = '2025-12-03 18:00:00'
>>> n = datetime.datetime.now(datetime.timezone.utc)
>>> tzhere = n.astimezone().tzinfo
>>> (n - parse_timestamp(job_updated, tzhere)).total_seconds()/3600
1.3768167161111111
>>> (n - parse_timestamp(job_updated)).total_seconds()/3600
1.3768167161111111

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.

2 participants