Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdk-heartbeat: null datetime conversion fix #813

Merged
merged 4 commits into from
Apr 20, 2022

Conversation

ivakoleva
Copy link
Contributor

@ivakoleva ivakoleva commented Apr 20, 2022

We've noticed an occasional error occurs, applying the stack trace:
File "/opt/buildenv/lib/python3.7/site-packages/vdk/internal/heartbeat/
job_controller.py", line 383, in check_job_execution_finished
self._datetime_from_iso_format(str(e["end_time"])) for e in
execution_list
TypeError: '>' not supported between instances of 'NoneType' and
'datetime.datetime'

The error seems to reproduce in case execution end_time is not yet
populated, and max() is attempting to compare datetime with NoneType.
The fix presumes the status of latest non-populated end_time is
freshest, so returns that if present. Otherwise, returns status of
latest end datetime populated. Discussion on workflow is found at
#813 (comment)
A broader Exception is added for handling during datetime conversion,
like a preventive step.

Testing done: did retrieve the Execution API response, did reproduce
same TypeError error via local code snippet, then verified the newly
introduced fix applied is operational. Did add a unit test to cover
this use-case.

Signed-off-by: ikoleva [email protected]

We've noticed an occasional error occurs, applying the stack trace:
File "/opt/buildenv/lib/python3.7/site-packages/vdk/internal/heartbeat/
job_controller.py", line 383, in check_job_execution_finished
self._datetime_from_iso_format(str(e["end_time"])) for e in
execution_list
TypeError: '>' not supported between instances of 'NoneType' and
'datetime.datetime'

The error seems to reproduce in case execution end_time is not yet
populated, and `max()` is attempting to compare datetime with NoneType.
The fix includes filtering out any empty end_times, so that we rely on
statuses and end_times populated only.
A broader Exception is added for handling during datetime conversion,
like a preventive step.

Testing done: did retrieve the Execution API response, did reproduce
same TypeError error via local code snippet, then verified the newly
introduced fix applied is operational.

Signed-off-by: ikoleva <[email protected]>
Copy link
Contributor

@doks5 doks5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

We've noticed an occasional error occurs, applying the stack trace:
File "/opt/buildenv/lib/python3.7/site-packages/vdk/internal/heartbeat/
job_controller.py", line 383, in check_job_execution_finished
self._datetime_from_iso_format(str(e["end_time"])) for e in
execution_list
TypeError: '>' not supported between instances of 'NoneType' and
'datetime.datetime'

The error seems to reproduce in case execution end_time is not yet
populated, and `max()` is attempting to compare datetime with NoneType.
The fix includes filtering out any empty end_times, so that we rely on
statuses and end_times populated only.
A broader Exception is added for handling during datetime conversion,
like a preventive step.

Testing done: did retrieve the Execution API response, did reproduce
same TypeError error via local code snippet, then verified the newly
introduced fix applied is operational.

Signed-off-by: ikoleva <[email protected]>
@ivakoleva ivakoleva enabled auto-merge (squash) April 20, 2022 15:50
@ivakoleva ivakoleva disabled auto-merge April 20, 2022 15:52
We've noticed an occasional error occurs, applying the stack trace:
File "/opt/buildenv/lib/python3.7/site-packages/vdk/internal/heartbeat/
job_controller.py", line 383, in check_job_execution_finished
self._datetime_from_iso_format(str(e["end_time"])) for e in
execution_list
TypeError: '>' not supported between instances of 'NoneType' and
'datetime.datetime'

The error seems to reproduce in case execution end_time is not yet
populated, and `max()` is attempting to compare datetime with NoneType.
The fix includes filtering out any empty end_times, so that we rely on
statuses and end_times populated only.
A broader Exception is added for handling during datetime conversion,
like a preventive step.

Testing done: did retrieve the Execution API response, did reproduce
same TypeError error via local code snippet, then verified the newly
introduced fix applied is operational.

Signed-off-by: ikoleva <[email protected]>
@antoniivanov
Copy link
Collaborator

Please add a unit test. It's a good idea to add a test(s) that verifies the bug is fixed (they should fail without the fix) -this way
A) we have better confidence in the fix
B) as bugs tend to resurface we have a regression check to make sure they do not.

@ivakoleva ivakoleva enabled auto-merge (squash) April 20, 2022 16:14
@ivakoleva ivakoleva disabled auto-merge April 20, 2022 16:15
@ivakoleva
Copy link
Contributor Author

Please add a unit test. It's a good idea to add a test(s) that verifies the bug is fixed (they should fail without the fix) -this way
A) we have better confidence in the fix
B) as bugs tend to resurface we have a regression check to make sure they do not.

We have a unit test, that failed - so I did rework and document the workflow considered,
see #813 (comment)

Or do you have something else in mind?

We've noticed an occasional error occurs, applying the stack trace:
File "/opt/buildenv/lib/python3.7/site-packages/vdk/internal/heartbeat/
job_controller.py", line 383, in check_job_execution_finished
self._datetime_from_iso_format(str(e["end_time"])) for e in
execution_list
TypeError: '>' not supported between instances of 'NoneType' and
'datetime.datetime'

The error seems to reproduce in case execution end_time is not yet
populated, and `max()` is attempting to compare datetime with NoneType.
The fix presumes the status of latest non-populated `end_time` is
freshest, so returns that if present. Otherwise, returns status of
latest end datetime populated. Discussion on workflow is found at
#813
#discussion_r854317775
A broader Exception is added for handling during datetime conversion,
like a preventive step.

Testing done: did retrieve the Execution API response, did reproduce
same TypeError error via local code snippet, then verified the newly
introduced fix applied is operational. Did add a unit test to cover
this use-case.

Signed-off-by: ikoleva <[email protected]>
@ivakoleva ivakoleva enabled auto-merge (squash) April 20, 2022 16:28
@ivakoleva ivakoleva merged commit ea7488a into main Apr 20, 2022
@ivakoleva ivakoleva deleted the person/ikoleva/datetime-conversion-fix branch April 20, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants