mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 02:03:01 +02:00
Fix a bug in which "borg --version" failing isn't considered a "fail" state in a command hook (#1100).
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
2.0.7.dev0
|
||||
* #1100: Fix a bug in which "borg --version" failing isn't considered a "fail" state in a command
|
||||
hook.
|
||||
|
||||
2.0.6
|
||||
* #1068: Fix a warning from LVM about leaked file descriptors.
|
||||
* #1086: Fix for the "spot" check breaking when the "--progress" flag is used.
|
||||
|
||||
@@ -228,7 +228,7 @@ def run_configuration(config_filename, config, config_paths, arguments):
|
||||
yield from log_error_records(
|
||||
f'{config_filename}: Error getting local Borg version', error
|
||||
)
|
||||
return
|
||||
raise
|
||||
|
||||
for repo in config['repositories']:
|
||||
repo_queue.put(
|
||||
@@ -289,11 +289,7 @@ def run_configuration(config_filename, config, config_paths, arguments):
|
||||
raise encountered_error
|
||||
|
||||
except (OSError, CalledProcessError, ValueError) as error:
|
||||
# No need to repeat logging of the error if it was already logged above.
|
||||
if error_repository:
|
||||
yield from log_error_records('Error running configuration')
|
||||
else:
|
||||
yield from log_error_records('Error running configuration', error)
|
||||
yield from log_error_records('Error running configuration')
|
||||
|
||||
encountered_error = error
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "borgmatic"
|
||||
version = "2.0.6"
|
||||
version = "2.0.7.dev0"
|
||||
authors = [
|
||||
{ name="Dan Helfman", email="witten@torsion.org" },
|
||||
]
|
||||
|
||||
@@ -2,6 +2,7 @@ import subprocess
|
||||
|
||||
from flexmock import flexmock
|
||||
|
||||
import borgmatic.hooks.command
|
||||
from borgmatic.commands import borgmatic as module
|
||||
|
||||
|
||||
@@ -42,6 +43,28 @@ def test_run_configuration_without_error_pings_monitoring_hooks_start_and_finish
|
||||
list(module.run_configuration('test.yaml', config, ['/tmp/test.yaml'], arguments))
|
||||
|
||||
|
||||
def test_run_configuration_with_borg_version_error_pings_after_command_hook_with_fail_state():
|
||||
config = {
|
||||
'repositories': [{'path': 'foo'}],
|
||||
'commands': ({'after': 'configuration', 'run': ['echo after'], 'states': ['fail']},),
|
||||
}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
flexmock(module.borg_version).should_receive('local_borg_version').and_raise(ValueError)
|
||||
flexmock(module).should_receive('run_actions').and_return([])
|
||||
flexmock(module.dispatch).should_receive('call_hooks')
|
||||
flexmock(borgmatic.hooks.command).should_receive('execute_hooks')
|
||||
flexmock(borgmatic.hooks.command).should_receive('execute_hooks').with_args(
|
||||
config['commands'],
|
||||
umask=object,
|
||||
working_directory=object,
|
||||
dry_run=False,
|
||||
log_file=object,
|
||||
configuration_filename=object,
|
||||
).once()
|
||||
|
||||
list(module.run_configuration('test.yaml', config, ['/tmp/test.yaml'], arguments))
|
||||
|
||||
|
||||
def test_run_configuration_with_action_error_pings_monioring_hooks_start_and_fail():
|
||||
config = {'repositories': [{'path': 'foo'}]}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
Reference in New Issue
Block a user