Merge pull request #39373 from varshar16/wip-fix-rook-timezone-error

mgr/rook: Add timezone info

Reviewed-by: Sebastian Wagner <sebastian.wagner@suse.com>
Reviewed-by: Travis Nielsen <tnielsen@redhat.com>
This commit is contained in:
Sebastian Wagner 2021-02-12 13:58:33 +01:00 committed by GitHub
commit 27a6c46f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,3 @@
import datetime
import threading
import functools
import os
@ -6,6 +5,7 @@ import json
from ceph.deployment import inventory
from ceph.deployment.service_spec import ServiceSpec, NFSServiceSpec, RGWSpec, PlacementSpec
from ceph.utils import datetime_now
from typing import List, Dict, Optional, Callable, Any, TypeVar, Tuple
@ -263,7 +263,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
service_type: Optional[str] = None,
service_name: Optional[str] = None,
refresh: bool = False) -> List[orchestrator.ServiceDescription]:
now = datetime.datetime.utcnow()
now = datetime_now()
# CephCluster
cl = self.rook_cluster.rook_api_get(

View File

@ -22,6 +22,7 @@ from urllib3.exceptions import ProtocolError
from ceph.deployment.drive_group import DriveGroupSpec
from ceph.deployment.service_spec import ServiceSpec, NFSServiceSpec, RGWSpec
from ceph.utils import datetime_now
from mgr_util import merge_dicts
from typing import Optional, TypeVar, List, Callable, Any, cast, Generic, \
@ -325,7 +326,7 @@ class RookCluster(object):
return False
return True
refreshed = datetime.datetime.utcnow()
refreshed = datetime_now()
pods = [i for i in self.rook_pods.items if predicate(i)]
pods_summary = []
@ -356,13 +357,13 @@ class RookCluster(object):
'created': None,
}
# note: we want UTC but no tzinfo
# note: we want UTC
if d['metadata'].get('creation_timestamp', None):
s['created'] = d['metadata']['creation_timestamp'].astimezone(
tz=datetime.timezone.utc).replace(tzinfo=None)
tz=datetime.timezone.utc)
if d['status'].get('start_time', None):
s['started'] = d['status']['start_time'].astimezone(
tz=datetime.timezone.utc).replace(tzinfo=None)
tz=datetime.timezone.utc)
pods_summary.append(s)