Skip to content

Commit

Permalink
Fix exception when attempting to write a datetime to db (sonic-net#5467)
Browse files Browse the repository at this point in the history
redis-py 3.0 used in master branch only accepts user data as bytes,
strings or numbers (ints, longs and floats). Attempting to specify a key
or a value as any other type will raise a DataError exception.
This PR address the issue bt converting datetime to str
  • Loading branch information
bingwang-ms authored and santhosh-kt committed Feb 25, 2021
1 parent a235f9c commit 0fa706b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions files/image_config/procdockerstatsd/procdockerstatsd
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ class ProcDockerStats(daemon_base.DaemonBase):
self.update_dockerstats_command()
datetimeobj = datetime.now()
# Adding key to store latest update time.
self.update_state_db('DOCKER_STATS|LastUpdateTime', 'lastupdate', datetimeobj)
self.update_state_db('DOCKER_STATS|LastUpdateTime', 'lastupdate', str(datetimeobj))
self.update_processstats_command()
self.update_state_db('PROCESS_STATS|LastUpdateTime', 'lastupdate', datetimeobj)
self.update_state_db('PROCESS_STATS|LastUpdateTime', 'lastupdate', str(datetimeobj))

# Data need to be updated every 2 mins. hence adding delay of 120 seconds
time.sleep(120)
Expand Down

0 comments on commit 0fa706b

Please sign in to comment.