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

Fix sentry spam errors #82

Merged
merged 4 commits into from
Dec 30, 2021

Conversation

ilyastrodubtsev
Copy link
Contributor

@ilyastrodubtsev ilyastrodubtsev commented Dec 29, 2021

Issue

Closes #79
Related #139
How
Add catching expected errors.

References
Change linter version: link

Improve catch error for is_concentrator_sx1302 func.
Change linter version
Add custom exception.
Check and catch new exception.
@ilyastrodubtsev ilyastrodubtsev force-pushed the ilyastarodubtsev/fix_sentry_spam_errors branch from a3ad28d to 36b5a3a Compare December 29, 2021 10:21
@ilyastrodubtsev ilyastrodubtsev marked this pull request as ready for review December 29, 2021 13:29
@ilyastrodubtsev ilyastrodubtsev requested a review from a team as a code owner December 29, 2021 13:29
pktfwd/utils.py Outdated
@@ -73,9 +81,12 @@ def is_concentrator_sx1302(util_chip_id_filepath, spi_bus):
return True
# CalledProcessError raised if there is a non-zero exit code
# https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module
except subprocess.CalledProcessError as e:
LOGGER.warning(e)
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to debug level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Level changed:

LOGGER.debug(e)

pktfwd/utils.py Outdated
@@ -207,10 +218,12 @@ def retry_start_concentrator(is_sx1302, spi_bus,
# lora_pkt_fwd exited without error. Attempt to restart the process
# by throwing an exception, which will trigger retry.
elif lora_pkt_fwd_proc_returncode == 0:
raise Exception("lora_pkt_fwd stopped without error.")
raise LoraPacketForwarderStopException(
Copy link
Contributor

Choose a reason for hiding this comment

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

rename exception: LoraPacketForwarderStoppedWithoutError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed:

raise LoraPacketForwarderStoppedWithoutError(

pktfwd/utils.py Outdated

# lora_pkt_fwd exited with error. Restart the container by letting
# the python application exit without error.
else:
LOGGER.error("lora_pkt_fwd stopped with code=%s." %
lora_pkt_fwd_proc_returncode)
raise LoraPacketForwarderStopWithStatusException(
Copy link
Contributor

Choose a reason for hiding this comment

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

The old code was correct. This is a real error, we need to fix the root cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roolback

hm-pktfwd/pktfwd/utils.py

Lines 222 to 224 in c953239

else:
LOGGER.error("lora_pkt_fwd stopped with code=%s." %
lora_pkt_fwd_proc_returncode)

Rollback changes on exit with an error.
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@@ -207,7 +214,8 @@ def retry_start_concentrator(is_sx1302, spi_bus,
# lora_pkt_fwd exited without error. Attempt to restart the process
# by throwing an exception, which will trigger retry.
elif lora_pkt_fwd_proc_returncode == 0:
raise Exception("lora_pkt_fwd stopped without error.")
raise LoraPacketForwarderStoppedWithoutError(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be LoraPacketForwarderStoppedWithError

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry this is correct.

@@ -207,7 +214,8 @@ def retry_start_concentrator(is_sx1302, spi_bus,
# lora_pkt_fwd exited without error. Attempt to restart the process
# by throwing an exception, which will trigger retry.
elif lora_pkt_fwd_proc_returncode == 0:
raise Exception("lora_pkt_fwd stopped without error.")
raise LoraPacketForwarderStoppedWithoutError(
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry this is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CalledProcessError: Command '['/opt/sx1302/chip_id', '-d', '/dev/spidev1.2']' returned non-zero exit status 1.
2 participants