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

[feature] Bypass-lock for "list" and "info" to prevent errors from metrics #18

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

spali
Copy link
Contributor

@spali spali commented Oct 3, 2024

temporary workaround for borgbackup/borg#7255 as cache is still locked

note:
needs more testing if this really works.

@spali
Copy link
Contributor Author

spali commented Oct 4, 2024

Don't know what I tested, but borgmatic doesn't pass the --bypass-lock down to borg.
it would work with borgmatic borg info and borgmatic borg list but requires to test the exact outputs, as at first, in case of multiple files, it returns multiple json objects but not as an array. So would need a bit different parsing.

@spali
Copy link
Contributor Author

spali commented Oct 4, 2024

Seems to run fine now using borgmatic borg .... Required a small method for parsing the output of multiple objects.
Don't know, why borgmatic is so inconstant in this regards ;(

@maxim-mityutko
Copy link
Owner

Please fix the tests: https://github.com/maxim-mityutko/borgmatic-exporter/actions/runs/11180616666/job/31124420057?pr=18
And also add the test for json_multi_parse. Thanks!

@maxim-mityutko maxim-mityutko changed the title bypass-lock for "list" and "info" to prevent errors from metrics [feature] Bypass-lock for "list" and "info" to prevent errors from metrics Oct 7, 2024
@maxim-mityutko maxim-mityutko merged commit b12e83a into maxim-mityutko:master Oct 7, 2024
2 of 3 checks passed
@maxim-mityutko
Copy link
Owner

Thank you for contributing!

@maxim-mityutko
Copy link
Owner

maxim-mityutko commented Oct 7, 2024

@spali I've bundled all the changes under the dev tag and deployed the container to test it.

Looks like the locking is still an issue, please try to deploy the dev container in your environment and see if it works or not...

Failed to create/acquire the lock /tmp/borgmatic-exporter-cache/.cache/borg/2654264492fcfe71af3a1662527e4947b950bc4838ea287f5e53cc4766f0e414/lock.exclusive (timeout).
remote-k8s-fs: Error running actions for repository
Command 'borg info --bypass-lock --json --last 1' returned non-zero exit status 73.
/etc/borgmatic.d/k8s-fs.yml: An error occurred
summary:
/etc/borgmatic.d/k8s-fs.yml: An error occurred
remote-k8s-fs: Error running actions for repository
Command 'borg info --bypass-lock --json --last 1' returned non-zero exit status 73.
Need some help? https://torsion.org/borgmatic/#issues
[2024-10-07 21:05:32,353] ERROR in app: Exception on /metrics [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/exporter/src/http_server.py", line 33, in metrics
    collect(borgmatic_config, registry)
  File "/exporter/src/metrics.py", line 82, in collect
    repos = run_command(
            ^^^^^^^^^^^^
  File "/exporter/src/metrics.py", line 179, in run_command
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['borgmatic', '-c', '/etc/borgmatic.d/', '--verbosity', '-1', 'borg', 'info', '--bypass-lock', '--json', '--last', '1']' returned non-zero exit status 1

@maxim-mityutko
Copy link
Owner

Not sure why that error popped up though, cause metrics scraping been working fine after I posted the message. I will keep an eye out for another day, if everything is ok, I will release the next version.

@spali
Copy link
Contributor Author

spali commented Oct 8, 2024

maybe container restart as the cache was locked.... but I don't like the implementation of borg/borgmatic anyway regarding this locking and readonly stuff.

Have the dev version also running now and didn't get a single error... just the warnings and override info per unencrypted repo:

Warning: Attempting to access a previously unknown unencrypted repository!
Do you want to continue? [yN] yes (from BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK)

@maxim-mityutko
Copy link
Owner

v0.2.6 is released and the image is available

@spali spali deleted the read_only branch October 9, 2024 13:46
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.

2 participants