-
Notifications
You must be signed in to change notification settings - Fork 121
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
Add an exponential backoff to harvester keep-alive notifications #326
Conversation
…i#307) This commits adds new notification for plot increases (e.g connecting HDD) and makes the notifications for increases/decreases configurable via the config for every integration.
* Add a scripts/linux/chiadog.service systemd example that attempts to run chiadog in a more isolated environment. Create a new limited user each run (making much of the filesystem readonly), and set `.chia/mainnet` folders other than `log` to inaccessible. * Move the offset file - previously, the `debug.log.offset` file was kept in the chiadog directory, but when running in a read only filesystem we can't write there. Create a temporary directory when running, and store the offset file there. This also means we no longer need to delete the offset file on startup.
Chia is [migrating their keyfiles](https://github.com/Chia-Network/chia-blockchain/wiki/Passphrase-Protected-Chia-Keys-and-Key-Storage-Migration) to `~/.chia_keys`. Block this folder from access in the systemd service.
…mi#314) Sometimes it is useful to disable SMTP authentication for sending emails. For example, if someone is using a local postfix server, the default install doesn't require/enable auth. When this new config option is set to enable_smtp_auth: false, the username_smtp and password_smtp config options are ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up with this! I have some feedback that needs to be addressed before I can upstream this. Let me know what you think.
if self._keep_alive_iteration[service] > 0: | ||
logging.info(f"incident for {service} is over") | ||
self._keep_alive_iteration[service] = 0 | ||
self._keep_alive_incident_time[service] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I'm looking at this, it's actually making this class more complex than I'd like (and really, a pain to maintain). It would be justified to refactor this into its own class. This will allow us to cover the functionality by unit tests too. I'd be hesitant to merge before we have some simple unit-test coverage.
As I see it, It should keep state for a single service, and then we can create instances for every service here. I'd propose the following interface (name can be better):
class EventThrottleHelper:
def __init__(self, interval_seconds: int):
self.event_counter = 0
self.first_event_time = None
self.interval_seconds = interval_seconds
def should_trigger_event(self):
time_now = datetime.now()
# Auto-detect when to reset event_counter and
# first_event_time based on current time,
# interval_seconds and first_event_time
where you initialize the class with the self._last_keep_alive_threshold_seconds[service]
and everything else can be encapsulated.
The change in KeepAliveMonitor
would then be very minimal, just extend the if-statement on line 80:
if seconds_since_last > self._last_keep_alive_threshold_seconds[service] and \
throttle_helper[service].should_trigger_event():
At first notifications will arrive roughly at the same speed as before but the delay starts increasing gradually over time. Keep-alive is still tested with the same frequency but failures in between notifications are only logged with the next notification threshold included. Fixes martomi#317
This wasn't caught earlier since the data from the Event isn't used yet. This is purely for future proofing so that the iteration count is available, even if not included in the message.
This had no practical application yet
f734943
to
260abab
Compare
Fixes #317
main
->dev
ghcr.io/artanicus/chiadog:keepalive_antispam-f73494