Skip to content

Commit 45725b4

Browse files
committed
replaced deprecated datetime.datetime.utcnow()
1 parent 3d8e406 commit 45725b4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

kube_downscaler/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def add_event(resource, message: str, reason: str, event_type: str, dry_run: boo
8585
.get_or_none()
8686
)
8787
if event and event.obj["message"] == message:
88-
now = datetime.datetime.utcnow()
88+
now = datetime.datetime.now(datetime.timezone.utc)
8989
timestamp = now.strftime("%Y-%m-%dT%H:%M:%SZ")
9090
event.obj["count"] = event.obj["count"] + 1
9191
event.obj["lastTimestamp"] = timestamp
@@ -100,7 +100,7 @@ def add_event(resource, message: str, reason: str, event_type: str, dry_run: boo
100100

101101

102102
def create_event(resource, message: str, reason: str, event_type: str, dry_run: bool):
103-
now = datetime.datetime.utcnow()
103+
now = datetime.datetime.now(datetime.timezone.utc)
104104
timestamp = now.strftime("%Y-%m-%dT%H:%M:%SZ")
105105
event = pykube.Event(
106106
resource.api,

tests/test_scaler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ def test_scaler_deployment_excluded_until(monkeypatch):
15211521
"kube_downscaler.scaler.helper.get_kube_api", MagicMock(return_value=api)
15221522
)
15231523

1524-
one_day_in_future = datetime.datetime.utcnow() + datetime.timedelta(days=1)
1524+
one_day_in_future = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
15251525

15261526
def get(url, version, **kwargs):
15271527
if url == "pods":

0 commit comments

Comments
 (0)