Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-101189

lib389/replica.py is using unexisting datetime.UTC in python3.9

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Critical Critical
    • rhel-9.7
    • rhel-9.7
    • 389-ds-base
    • None
    • 389-ds-base-2.7.0-3.el9
    • Yes
    • Low
    • ZStream
    • rhel-idm-ds
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • No
    • None
    • Regression Exception
    • Release Note Not Required
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      On RHEL 9.7, install an IPA server and a replica, install ipa-healthcheck, then call ipa-healthcheck.

      The command fails in the check ipahealthcheck.ds.replication / ReplicationCheck with an exception in lib389/replica.py: module 'datetime' has no attribute 'UTC'

      What is the impact of this issue to you?

      The command ipa-healthcheck is broken.

      Please provide the package NVR for which the bug is seen:

      389-ds-base-2.7.0-2.el9.x86_64

      python3-3.9.23-1.el9.x86_64

       

      How reproducible is this bug?:

      always

      Steps to reproduce

      1. (on master and replica) dnf install -y ipa-server ipa-healthcheck
      2. (on master) ipa-server-install --domain ipa.test --realm IPA.TEST -a Secret123 -p Secret123 -U
      3. (on replica) ipa-replica-install --domain ipa.test --realm IPA.TEST --principal admin --password Secret123 -U --server <masterfqdn>
      4. ipa-healthcheck --source ipahealthcheck.ds.replication --check ReplicationCheck

      Expected results

      Success

      Actual results

      The command fails with:

      # ipa-healthcheck --source ipahealthcheck.ds.replication --check ReplicationCheck
      [
        {
          "source": "ipahealthcheck.ds.replication",
          "check": "ReplicationCheck",
          "result": "CRITICAL",
          "uuid": "18b55700-a406-4b2f-ada0-4a1235b542ac",
          "when": "20250701081923Z",
          "duration": "0.352202",
          "kw": {
            "exception": "module 'datetime' has no attribute 'UTC'",
            "traceback": "Traceback (most recent call last):\n  File \"/usr/lib/python3.9/site-packages/ipahealthcheck/core/core.py\", line 56, in run_plugin\n    for result in plugin.check():\n  File \"/usr/lib/python3.9/site-packages/ipahealthcheck/core/plugin.py\", line 18, in wrapper\n    for result in f(*args, **kwds):\n  File \"/usr/lib/python3.9/site-packages/ipahealthcheck/ds/plugin.py\", line 108, in check\n    results = self.doCheck(self.check_class, self.many)\n  File \"/usr/lib/python3.9/site-packages/ipahealthcheck/ds/plugin.py\", line 97, in doCheck\n    for result in results:\n  File \"/usr/lib/python3.9/site-packages/lib389/_mapped_object_lint.py\", line 126, in lint\n    yield from f()\n  File \"/usr/lib/python3.9/site-packages/lib389/replica.py\", line 1325, in _lint_no_ruv\n    ruv_dict = ruv.format_ruv()\n  File \"/usr/lib/python3.9/site-packages/lib389/replica.py\", line 949, in format_ruv\n    \"csn\": RUV().parse_csn(self._rid_csn.get(rid, '00000000000000000000')),\n  File \"/usr/lib/python3.9/site-packages/lib389/replica.py\", line 920, in parse_csn\n    time_str = datetime.datetime.fromtimestamp(timestamp, datetime.UTC).strftime('%Y-%m-%d %H:%M:%S')\nAttributeError: module 'datetime' has no attribute 'UTC'\n"
          }
        }
      ]
       

       

      The lib389 was changed with the rebase to 389-ds-base 2.7 which introduced this commit:

      https://github.com/389ds/389-ds-base/commit/62cfa7a8527df167db5793fa29ec270cb06981e6

      and changed the method parse_csn (https://github.com/389ds/389-ds-base/blob/389-ds-base-2.7/src/lib389/lib389/replica.py#L920) in src/lib389/lib389/replica.py to use datetime.UTC. The issue is that this attribute was added in python 3.11 (https://docs.python.org/3/library/datetime.html#datetime.UTC) and doesn't exist in python 3.9 which is the version shipped in RHEL 9.7.

              idm-ds-dev-bugs IdM DS Dev
              frenaud@redhat.com Florence Renaud
              IdM DS Dev IdM DS Dev
              IdM DS QE IdM DS QE
              Evgenia Martyniuk Evgenia Martyniuk
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: