Bug 2186608 - The timezone validity filter in anaconda rejects valid timezones that RHEL6 (and 7) accepted
Summary: The timezone validity filter in anaconda rejects valid timezones that RHEL6 (...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: anaconda
Version: 8.7
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Anaconda Maintenance Team
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On: 1452873
Blocks: 2129764
TreeView+ depends on / blocked
 
Reported: 2023-04-13 19:48 UTC by Frank Hirtz
Modified: 2023-06-29 09:47 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1452873
: 2186720 (view as bug list)
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-154653 0 None None None 2023-04-13 19:51:19 UTC

Comment 1 Frank Hirtz 2023-04-13 19:55:23 UTC
Client reported this in late testing on their RHEL8 migration and I did a quick reproduction: 

~~~
Validation on 8.6:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@localhost ~]# grep timezone anaconda-ks.cfg 
# System timezone
timezone Japan
[root@localhost ~]# timedatectl 
               Local time: Thu 2023-04-13 15:31:14 EDT
           Universal time: Thu 2023-04-13 19:31:14 UTC
                 RTC time: Thu 2023-04-13 15:31:14
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
[root@localhost ~]# grep -i japan syslog
19:12:27,036 WARNING org.fedoraproject.Anaconda.Modules.Timezone:DEBUG:anaconda.modules.timezone.timezone:Timezone is set to Japan.
19:19:33,330 WARNING org.fedoraproject.Anaconda.Modules.Timezone:WARNING:anaconda.modules.timezone.installation:Timezone Japan set in kickstart is not valid, falling back to default (America/New_York).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Checking the 8.7 tree in git:

pyanaconda/modules/timezone/installation.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def _correct_timezone(self):              
        """Ensure the timezone is valid."""   
        if not is_valid_timezone(self._timezone):     
            # this should never happen, but for pity's sake
            log.warning("Timezone %s set in kickstart is not valid, "
                        "falling back to default (America/New_York).", self._timezone)
            self._timezone = "America/New_York"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pyanaconda/timezone.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def is_valid_timezone(timezone):
    """
    Check if a given string is an existing timezone.
     
    :type timezone: str
    :rtype: bool
     
    """
     
    etc_zones = ["Etc/" + zone for zone in ETC_ZONES]
     
    return timezone in pytz.common_timezones + etc_zones
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


So, we're filtering against pytz.common_timezones here regardless of the method. 

It looks like the RHEL7 fix didn't make the RHEL8 tree, though it looks like it was inteneded to:

https://github.com/rhinstaller/anaconda/pull/1149/commits/831d200b575c300b8d0b917d0626404484accc0a

I don't suspect that this was intentional given that it's at odds with the documentation:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/performing_an_advanced_rhel_8_installation/index#timezone-required_kickstart-commands-for-system-configuration

~~~
B.3.15. timezone (required)
The timezone Kickstart command is required. It sets the system time zone.

Syntax

timezone timezone [OPTIONS]
Mandatory options

timezone - the time zone to set for the system.
Optional options

--utc - If present, the system assumes the hardware clock is set to UTC (Greenwich Mean) time.
--nontp - Disable the NTP service automatic starting.
--ntpservers= - Specify a list of NTP servers to be used as a comma-separated list without spaces.
Notes

In Red Hat Enterprise Linux 8, time zone names are validated using the pytz.all_timezones list, provided by the pytz package. In previous releases, the names were validated against pytz.common_timezones, which is a subset of the currently used list. Note that the graphical and text mode interfaces still use the more restricted pytz.common_timezones list; you must use a Kickstart file to use additional time zone definitions.
~~~
Checking on a RHEL8 host to see what that defines:
~~~
>>> pytz.all_timezones
['CET', 'CST6CDT', 'EET', 'EST', 'EST5EDT', 'HST', 'MET', 'MST', 'MST7MDT', 'PST8PDT', 'WET', 'leapseconds', 'Iceland', 'Egypt', 'Libya', 'Navajo', 'Cuba', 'Jamaica', 'posixrules', 'NZ', 'PRC', 'Hongkong', 'Turkey', 'Israel', 'Singapore', 'ROK', 'ROC', 'Iran', 'Japan', 'Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich', 'UCT', 'UTC', 'Universal', 'Zulu', 'GB', 'GB-Eire', 'Portugal', 'W-SU', 'Poland', 'Kwajalein', 'NZ-CHAT',...
~~~

Comment 2 Jan Stodola 2023-04-14 08:41:08 UTC
Also reproducible on RHEL-9, reported as bug 2186720.

Fedora Rawhide doesn't suffer by this problem, most likely due to https://github.com/rhinstaller/anaconda/pull/3167


Note You need to log in before you can comment on or make changes to this bug.