Skip to content

Commit

Permalink
Merge pull request Kuadrant#405 from averevki/self-aware-datetime
Browse files Browse the repository at this point in the history
Fix timezone aware time deprecation warning
  • Loading branch information
averevki authored May 21, 2024
2 parents 840c1bb + d8a47c7 commit f1eb523
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 f1eb523

Please sign in to comment.