Skip to content

Conversation

emmanuel-ferdman
Copy link

@emmanuel-ferdman emmanuel-ferdman commented May 13, 2025

Description

This small PR resolves the datetime library warnings:

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). or datetime.datetime.utcnow()

Related Issues

Testing

Tests.

Checklist

  • Does my change need to be backported to a previous release?

    • What backport versions were discussed with the Maintainers in the Issue?
  • I made sure to update CHANGELOG.md.

    Remember, the CHANGELOG needs to mention:

    • Any new features
    • Any changes to our included version of Envoy
    • Any non-backward-compatible changes
    • Any deprecations
  • This is unlikely to impact how Ambassador performs at scale.

    Remember, things that might have an impact at scale include:

    • Any significant changes in memory use that might require adjusting the memory limits
    • Any significant changes in CPU use that might require adjusting the CPU limits
    • Anything that might change how many replicas users should use
    • Changes that impact data-plane latency/scalability
  • My change is adequately tested.

    Remember when considering testing:

    • Your change needs to be specifically covered by tests.
      • Tests need to cover all the states where your change is relevant: for example, if you add a behavior that can be enabled or disabled, you'll need tests that cover the enabled case and tests that cover the disabled case. It's not sufficient just to test with the behavior enabled.
    • You also need to make sure that the entire area being changed has adequate test coverage.
      • If existing tests don't actually cover the entire area being changed, add tests.
      • This applies even for aspects of the area that you're not changing – check the test coverage, and improve it if needed!
    • We should lean on the bulk of code being covered by unit tests, but...
    • ... an end-to-end test should cover the integration points
  • I updated CONTRIBUTING.md with any special dev tricks I had to use to work on this code efficiently.

  • The changes in this PR have been reviewed for security concerns and adherence to security best practices.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. deprecation python Pull requests that update Python code labels May 13, 2025
@emmanuel-ferdman
Copy link
Author

@the-wondersmith could you please review this small PR when you get the chance? thanks 😄

@the-wondersmith
Copy link

@emmanuel-ferdman Just for the sake of due diligence, do you happen to know where the deprecation schedule associated with the warning is? Just want to make sure the change is compatible across the (admittedly narrow) range of Python versions emissary needs to comply with.

@emmanuel-ferdman
Copy link
Author

@the-wondersmith thanks for the review. The datetime.utcnow() function was deprecated in Python 3.12 and is scheduled for removal in Python 3.14. The recommended replacement using timezone-aware objects (datetime.now(timezone.utc)) has been available since Python 3.2 when the datetime.timezone class was introduced, providing a backward-compatible solution that works across all currently supported Python versions while properly handling UTC timezone awareness.

@the-wondersmith
Copy link

... thanks for the review.

My pleasure 😁

{...} recommended replacement using timezone-aware objects (datetime.now(timezone.utc)) has been available since Python 3.2 {...}

that'll do it

Copy link

@the-wondersmith the-wondersmith left a comment

Choose a reason for hiding this comment

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

approved

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 28, 2025
@emmanuel-ferdman
Copy link
Author

@the-wondersmith anything else is needed from my side? thanks 😄

@the-wondersmith
Copy link

@emmanuel-ferdman No, I don't think so. But it looks like CI isn't being cooperative. @kflynn do you have a lever to pull here?

@emmanuel-ferdman
Copy link
Author

@the-wondersmith @kflynn how can we progress from here? 🙌

@the-wondersmith
Copy link

^ bump @kflynn

@emmanuel-ferdman
Copy link
Author

Hi @kflynn, how can we progress with this PR? thanks 😄

@kflynn
Copy link
Member

kflynn commented Aug 21, 2025

Hey @emmanuel-ferdman, so sorry for the silence here! I think the way forward here is going to be the dev/v4 branch: Emissary 3 relies on a custom version of Envoy that's... prohibitive... to build these days.

We're in the middle of getting CI to properly run there, so hang tight for a bit longer and we'll get this moved over. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecation lgtm This PR has been approved by a maintainer python Pull requests that update Python code size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants