Skip to content

Commit 99ae4ed

Browse files
authored
sq-poller: fix backward compatibility with old data (+ upgrade pyarrow to 10.0.1) (#835)
* sq-poller: check if deviceSession is nan Signed-off-by: Claudio Lorina <[email protected]> * Bump pyarrow version up to 10.0.1 Signed-off-by: Claudio Lorina <[email protected]> * sq-poller: add comment to deviceSession check Signed-off-by: Claudio Lorina <[email protected]> Signed-off-by: Claudio Lorina <[email protected]>
1 parent 412b324 commit 99ae4ed

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

poetry.lock

Lines changed: 27 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ textfsm = "*"
2323
async-timeout = "<4.0"
2424
aiofiles = "*"
2525
prompt-toolkit = ">2"
26-
pyarrow = "8.0.0"
26+
pyarrow = "10.0.1"
2727
pandas = "1.3.4"
2828
PyYAML = "*"
2929
python-nubia = "0.2b5"

suzieq/poller/worker/services/service.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,16 @@ async def commit_data(self, result: Dict, namespace: str, hostname: str,
630630
namespace=[namespace]).query('active')
631631
# Get the latest device session we have written with this service
632632
if not df.empty:
633-
last_device_session = df['deviceSession'].iloc[0] or 0
633+
# If we are dealing with old data then the value of
634+
# deviceSession will be unset, if this is the case, set the
635+
# value to 0 so that we force write. We need to check only
636+
# the first value of deviceSession as it is equal for all the
637+
# latest record, as in case of reboot we rewrite everything.
638+
if not df['deviceSession'].iloc[:1].isnull().any():
639+
last_device_session = df['deviceSession'].iloc[0] or 0
640+
else:
641+
last_device_session = 0
642+
634643
self._node_boot_timestamps[key] = int(last_device_session)
635644

636645
prev_res = df.to_dict('records')

0 commit comments

Comments
 (0)