[ycabled] fix exception-handling logic for ycabled#306
[ycabled] fix exception-handling logic for ycabled#306prgeor merged 24 commits intosonic-net:masterfrom
Conversation
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 2 alerts when merging e3cd1a0 into 23b6970 - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 1 alert when merging 68e9412 into 23b6970 - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
Signed-off-by: vaibhav-dahiya <[email protected]>
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 2 alerts when merging cc96144 into 4ea12cf - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 3 alerts when merging 81cf7ca into 4ea12cf - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
Signed-off-by: vaibhav-dahiya <[email protected]>
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging b898ffa into 4ea12cf - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 2807278 into 4ea12cf - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 3cfc033 into 4ea12cf - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 2c14791 into 4ea12cf - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging a71b11b into 9ae551f - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging e92c74f into 9ae551f - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 9745e6a into 9ae551f - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
| asic_index = 0 | ||
| logical_port_name = "Ethernet0" | ||
| mux_tbl = Table("STATE_DB", "Y_CABLE_INFO_TABLE") | ||
| rc = post_port_mux_info_to_db(logical_port_name, mux_tbl,'active-standby') |
There was a problem hiding this comment.
can we add a test to crash at known location and see if we print backtrace ?
There was a problem hiding this comment.
UT is added, fixed
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 1ac2a2b into 905874d - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 56c48ef into 905874d - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 2e19b16 into 905874d - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging e23540c into 905874d - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 0bd7cfb into 905874d - view on LGTM.com new alerts:
|
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 2061ab1 into 905874d - view on LGTM.com new alerts:
|
sonic-ycabled/tests/test_ycable.py
Outdated
|
|
||
| os.environ["YCABLE_UNIT_TESTING"] = "1" | ||
|
|
||
| exception_output_expected= """\ |
There was a problem hiding this comment.
will this work if python version changes in future?
There was a problem hiding this comment.
this would not be backwards compatible, thats why I had added some string checks only,
Better to omit this check I think.
sonic-ycabled/tests/test_ycable.py
Outdated
| assert(expected_exception_start.args == expected_exception_join.args) | ||
| assert("NotImplementedError" in str(trace) and "effect" in str(trace)) | ||
| assert("sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py" in str(trace)) | ||
| assert("line 3655" in str(trace)) |
There was a problem hiding this comment.
can the line no change if the code changes?
There was a problem hiding this comment.
yes line number will change and assert will have to be updated.
Maybe we need to just focus on the trace lines
Signed-off-by: vaibhav-dahiya <[email protected]>
|
This pull request introduces 4 alerts when merging 419e742 into 905874d - view on LGTM.com new alerts:
|
Cherry-pick conflict #306 Signed-off-by: vaibhav-dahiya [email protected] This PR is changing how exception handling is handled in python threading. In python3.7 if child thread gets an exception, there is no way of knowing an exception occured, unless a join is called. The problem is resolved in this PR Also task classes are structured this way class YcableInfoUpdateTask(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.exc = None def run(self): if self.task_stopping_event.is_set(): return self.task_thread = threading.Thread(target=self.task_worker, args=(y_cable_presence,)) self.task_thread.start() try: self.task_worker(self.y_cable_presence) except Exception as e: helper_logger.log_error("Exception occured at child thread YcableInfoUpdateTask due to {} {}".format(repr(e), traceback.format_exc())) self.exc = e def join(self): threading.Thread.join(self) if self.exc: raise self.exc This allows helping catching the exception thrown by a child thread get caught along with traceback. Main thread has a while loop, which monitors each thread, if not running will kill the whole process and supervisord will bring back the ycabled up. Description Motivation and Context How Has This Been Tested? Unit-tests and deploying changes on testbed Additional Information (Optional) sonic-mgmt tests which pass with this change /var/src/sonic-mgmt-int/tests/logs/dualtor/test_ipinip.py::test_decap_active_tor /var/src/sonic-mgmt-int/tests/logs/dualtor/test_ipinip.py::test_decap_standby_tor /var/src/sonic-mgmt-int/tests/logs/dualtor/test_toggle_mux /var/src/sonic-mgmt-int/dualtor_io/test_link_failure.py::test_standby_tor_downlink_down_downstream_active /var/src/sonic-mgmt-int/tests/logs/platform_tests/api/test_chassis.py
…nic-net#306) * update the return for update_firmware api's failure case when the image file doesn't exist * update comments * update comment * update comment
Signed-off-by: vaibhav-dahiya [email protected]
This PR is changing how exception handling is handled in python threading.
In python3.7 if child thread gets an exception, there is no way of knowing an exception occured, unless a join is called. The problem is resolved in this PR
Also task classes are structured this way
This allows helping catching the exception thrown by a child thread get caught along with traceback.
Main thread has a while loop, which monitors each thread, if not running will kill the whole process and supervisord will bring back the ycabled up.
Description
Motivation and Context
How Has This Been Tested?
Unit-tests and deploying changes on testbed
Additional Information (Optional)
sonic-mgmt tests which pass with this change
No exceptions observed, ycabled seems healthy with true thread count