aws / efs-utils

Utilities for Amazon Elastic File System (EFS)
MIT License
285 stars 187 forks source link

Use timezone-aware objects to resolve DeprecationWarning with Python 3.12 #217

Closed DBS-ST-VIT closed 2 months ago

DBS-ST-VIT commented 3 months ago

Issue #, if available: #187

Description of changes: This PR fixes a deprecation that came up with the datetime library under Python 3.12. The watchdog is currently spamming the deprecation warning 2 times per seconds / 120 times per minute into the syslog - fixing the deprecation will resolve this issue.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

bugfood commented 3 months ago

I think that that your patch is correct.

Fedora (and RHEL) have this patched too, as far as I can tell.

https://src.fedoraproject.org/rpms/efs-utils/blob/rawhide/f/0001-fix-timezone.patch

The key difference is that this PR includes replace(tzinfo=timezone.utc), which is necessary in order to avoid:

$ sudo /usr/bin/amazon-efs-mount-watchdog
Traceback (most recent call last):
  File "/usr/bin/amazon-efs-mount-watchdog", line 2162, in <module>
    main()
  File "/usr/bin/amazon-efs-mount-watchdog", line 2152, in main
    unmount_count_for_consistency,
  File "/usr/bin/amazon-efs-mount-watchdog", line 1146, in check_efs_mounts
    check_certificate(config, state, state_file_dir, state_file)
  File "/usr/bin/amazon-efs-mount-watchdog", line 1361, in check_certificate
    get_utc_now() - certificate_creation_time
TypeError: can't subtract offset-naive and offset-aware datetimes

(that's from the efs-utils-1.36.0-3.fc40.noarch RPM, so line numbers will not match current git)

mskanth972 commented 3 months ago

Hi @DBS-ST-VIT, thanks for the PR. We are looking forward to merge it and release in the upcoming version.

DBS-ST-VIT commented 2 months ago

Hi @DBS-ST-VIT, thanks for the PR. We are looking forward to merge it and release in the upcoming version.

Hello, are there any news regarding the upcoming version and when it will be released?

This bug is still creating Gigabytes of log garbage per day in our accounts and colleagues of SIEM already asked me, what in hell we are doing here and why theres no fix for that bug.

anthotse commented 2 months ago

Hey @DBS-ST-VIT, thanks again for the PR. We've included the fix, along with updates to unit tests needed to validate the fix in v2.0.3.