SIGTERM is not terminating borgmatic #516

Closed
opened 2022-03-31 15:37:12 +00:00 by NED567 · 3 comments

What I'm trying to do and why

I am using borgmatic on debian/testing. There borgmatic is started by a systemd timer and service. Stopping or restarting the service while borgmatic is creating an archive doesn't work.

Steps to reproduce (if a bug)

  • Create multiple configuration files in /etc/borgmatic.d/
    (it looks like it can also be 1 configuration file with multiple repositories)
  • Start /usr/bin/borgmatic --verbosity 1
  • While borgmatic is working (prune/create/...) on the first repository, stop it from an other terminal with pkill --signal TERM borgmatic.

Actual behavior (if a bug)

The work on the first repository is stopped, but borgmatic continues on the next repository.

Expected behavior (if a bug)

borgmatic should stop the current running action (of borg) and then terminate.

Other notes / implementation ideas

The signal SIGTERM indicates for a process that it needs to be stopped. The process is allowed to clean up it's environment (release locks) but then should stop as soon as possible. It should not start new long lasting actions.

It looks like the method _handle_signal only propagates the SIGTERM to the subprocesses, but the current process (borgmatic) can just continue (with the next repository). This is not correct. Borgmatic should stop as well.

Environment

borgmatic version: [1.5.20]

borgmatic installation method: [Debian package]

Borg version: [borg 1.2.0]

Python version: [Python 3.9.12]

Database version (if applicable): [N/A]

operating system and version: [debian testing]

#### What I'm trying to do and why I am using borgmatic on debian/testing. There borgmatic is started by a systemd timer and service. Stopping or restarting the service while borgmatic is creating an archive doesn't work. #### Steps to reproduce (if a bug) * Create multiple configuration files in /etc/borgmatic.d/ (it looks like it can also be 1 configuration file with multiple repositories) * Start `/usr/bin/borgmatic --verbosity 1` * While borgmatic is working (prune/create/...) on the first repository, stop it from an other terminal with `pkill --signal TERM borgmatic`. #### Actual behavior (if a bug) The work on the first repository is stopped, but borgmatic continues on the next repository. #### Expected behavior (if a bug) borgmatic should stop the current running action (of borg) and then terminate. #### Other notes / implementation ideas The signal SIGTERM indicates for a process that it needs to be stopped. The process is allowed to clean up it's environment (release locks) but then should stop as soon as possible. It should not start new long lasting actions. It looks like the method `_handle_signal` only propagates the SIGTERM to the subprocesses, but the current process (borgmatic) can just continue (with the next repository). This is not correct. Borgmatic should stop as well. #### Environment **borgmatic version:** [1.5.20] **borgmatic installation method:** [Debian package] **Borg version:** [borg 1.2.0] **Python version:** [Python 3.9.12] **Database version (if applicable):** [N/A] **operating system and version:** [debian testing]
Owner

Good catch! Looks like it's indeed a bug based on the code, although I haven't yet verified with a local repro. Thank you for filing this.

EDIT: Got a local repro now.

Good catch! Looks like it's indeed a bug based on the code, although I haven't yet verified with a local repro. Thank you for filing this. EDIT: Got a local repro now.
witten added the
bug
label 2022-04-01 03:47:59 +00:00
Owner

This has been fixed in master! It'll be part of the next release. Thanks again.

This has been fixed in master! It'll be part of the next release. Thanks again.
Owner

Released in borgmatic 1.6.0!

Released in borgmatic 1.6.0!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#516
No description provided.