Skip to content

Commit

Permalink
Fix timezone aware time deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
averevki committed May 21, 2024
1 parent 840c1bb commit d8a47c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions testsuite/openshift/metrics/prometheus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Simple client for the OpenShift metrics"""

from typing import Callable
from datetime import datetime
from datetime import datetime, timezone

import backoff
from apyproxy import ApyProxy
Expand Down Expand Up @@ -72,7 +72,7 @@ def get_metrics(self, key: str = "", labels: dict[str, str] = None) -> Metrics:

def wait_for_scrape(self, target_service: str, metrics_path: str = "/metrics"):
"""Wait before next metrics scrape on service is finished"""
call_time = datetime.utcnow()
call_time = datetime.now(timezone.utc)

@backoff.on_predicate(backoff.constant, interval=10, jitter=None, max_tries=20)
def _wait_for_scrape():
Expand All @@ -83,7 +83,7 @@ def _wait_for_scrape():
and target["labels"]["service"] == target_service
and target["discoveredLabels"]["__metrics_path__"] == metrics_path
):
return call_time < datetime.fromisoformat(target["lastScrape"][:26])
return call_time < datetime.fromisoformat(target["lastScrape"][:26]).replace(tzinfo=timezone.utc)
return False

assert _wait_for_scrape(), "Prometheus didn't reconcile ServiceMonitor in time"
Expand Down

0 comments on commit d8a47c7

Please sign in to comment.