Bug description

Hello, I've encountered a timezone handling issue in Apache Superset version 3.0.1. The timezone setting for my report is configured to Australia/Perth, which aligns with the timezone of the server where Superset is installed.

Despite being set to trigger at 10:00 AM daily, the actual triggering time for the report occurs at 7:00 PM, leading to a delay of 9 hours.

Currently, we are using Apache Superset version 3.0.1 that internally uses Python version 3.9.8. Upon investigation, it appears that there might be an issue with timezone conversion in this specific code snippet from superset/tasks/cron_util.py in the 3.0.1 release: time_now = triggered_at.astimezone(tz) There seems to be a problem with the conversion specifically in Python 3.9.8, while it works as expected in Python 3.8.

The issue can potentially be resolved by modifying the code in Python 3.9.8 as follows: tz_temp = ZoneInfo(tz.zone) time_now = triggered_at.astimezone(tz_temp)

How to reproduce the bug

1.Go to Alert&Report 2.Configure a scheduled report, for example: Daily at 16:00 (based on your server's timezone). If you do not receive the report email at exactly 16:00, it is possible that the email may be delayed or arrive earlier, depending on your server's timezone.

Screenshots/recordings

No response

Superset version

3.0.3

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: michael-s-molina

Hi @liangliangGit. Are you able to reproduce this issue using Superset 3.0.3?

From our issue instructions:

If your environment does not match the alternatives, you need to upgrade your environment before submitting the issue as it may have already been fixed.

Comment From: liangliangGit

Hi @liangliangGit. Are you able to reproduce this issue using Superset 3.0.3?

From our issue instructions:

If your environment does not match the alternatives, you need to upgrade your environment before submitting the issue as it may have already been fixed.

Hi @michael-s-molina , I haven't had the chance to test this issue in a 3.0.3 environment due to internal company constraints on setting up such an environment. However, I have compared the code between versions 3.0.1 and 3.0.3, and found no differences in the relevant code sections. Also, after reviewing the CHANGELOG.md file, I did not find any related fixes documented for this issue. Here is the code for both versions 3.0.1 and 3.0.3: https://github.com/apache/superset/blob/3.0.1/superset/tasks/cron_util.py https://github.com/apache/superset/blob/3.0.3/superset/tasks/cron_util.py https://github.com/apache/superset/blob/3.0.1/superset/tasks/scheduler.py https://github.com/apache/superset/blob/3.0.3/superset/tasks/scheduler.py

By the way, in the file(https://github.com/apache/superset/blob/3.0.3/superset/tasks/scheduler.py), it's possible that datetime.utcnow() should be replaced with datetime.now(timezone.utc).

my docker-compose configuration(environment: TZ=Asia/Tokyo): docker-compose-3.0.1.txt

Comment From: liangliangGit

In version 3.1.0, there is still an issue. My docker-compose.yml file (docker-compose.txt) specifies the timezone(environment: TZ=Asia/Tokyo) within it. On the report web page, the configured TIMEZONE is GMT +09:00 (Australia/Perth). @michael-s-molina

Comment From: michael-s-molina

Thanks @liangliangGit for checking. As soon as we have a fix for the issue, I'll cherry-pick it into supported versions.

Comment From: nathan-gilbert

This seems similar to what I am experiencing as well: https://github.com/apache/superset/issues/27952

Comment From: rusackas

This has been silent for upward of a year, but I'm worried about closing this particular one as stale. Can anyone give an update?

Comment From: rusackas

We haven't heard any updates, or whether this is an issue in 4.1.x, so I'll close this as "not planned" for now. Happy to reopen this if it's still relevant!