Repository navigation
Centralise Borg repo/archive arguments and fix Borg 2 drift - #2617
Merged
Merged
Conversation
Every job built its repository and archive arguments with its own Borg 1/2 branch. The Borg 2 branches are not exercised by CI and had drifted apart. Add BorgCompatibility.repo_args() and match_archive() and use them at all sites; only delete's multi-archive regex, the prune prefix filter and the repo-* subcommand names stay at their call sites. Borg 1 argv is unchanged everywhere. Borg 2 fixes on the way: - break-lock passes the repo with -r instead of positionally - check of a selected archive uses -a id:NAME instead of -r URL::NAME; the archive is now passed to BorgCheckJob.prepare instead of being appended to cmd by the view - mounting an archive uses -a id:NAME instead of a mangled shell escape - mount detection parses the command line by option, so archive mounts are recognised again and map archive name to mount point - delete escapes regex metacharacters in archive names - info uses -a id:NAME, so a name starting with a pattern prefix is matched literally Break-lock no longer reports success when Borg failed (Borg 1 and 2). Fixes #2601
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Every Borg job built its repository/archive arguments with its own
if borg_compat.check('V2')branch. This adds two helpers onBorgCompatibilityand uses them at all 16 sites:repo_args(url, archive=None, *, match=False): Borg 1 gives[url]or[url::archive]; Borg 2 gives['-r', url],['-r', url, archive], or withmatch=True['-r', url, '-a', 'id:<archive>']for commands that have no archive positional.match_archive(name): the Borg 2--match-archivesvalue for exactly that name (id:<name>).What stays at the call site: delete's multi-archive regex on Borg 2, the prune prefix filter (three version tiers), and the
repo-info/repo-list/repo-createsubcommand names.Borg 1 argv is unchanged at every site. The helpers only append to
cmd, socmd[1](stored asEventLogModel.subcommandand queried by the scheduler) does not move.Borg 2 fixes:
break-lock ... URL(no positional exists in Borg 2)break-lock ... -r URL-r URL::NAME-r URL -a id:NAME-awith a mangled name (a*b[c]?becamea\1b\1c\1\1)-a id:NAME{'-a': NAME}{NAME: mount_point}, as the Borg 1 parser and the views expect-a re:(a|b)from raw names-a re:(?:a|b)with each name passed throughre.escape-a NAME-a id:NAMEAlso, on Borg 1 and 2: break-lock reported "Repository lock broken" whatever the return code. It now shows a failure message with a link to the logs for a non-zero return code. This adds one translatable string; the catalogs are not regenerated here.
Other changes:
BorgCheckJob.prepare(profile, archive=None)takes the archive; the view no longer appends::NAMEtocmd[-1].extract_mount_points_v2parses the command line by option instead of by position. It accepts short, long and joined forms, skips the values of other value-taking options, ignores--match-archivespatterns that are not a single name (sh:,re:,aid:, ...), and never raises on a truncated or foreign command line.SHELL_PATTERN_ELEMENTis gone.info_repo/list_reporead the URL fromparams['repo_url']instead ofcmd[-1].Related Issue
Fixes #2601
Motivation and Context
The Borg 2 branches are not exercised by CI and had drifted: one was missing, one was applied from outside the job, and the archive name was quoted three different ways. See the issue for the six bugs.
Known limitations
rcreate, so a Borg 2 CI job needs its own change.id:cannot simply be added at those sites.id:NAMEand delete'sre:can match more than one archive.break_lock.py'sfinished_event; whichever is merged second needs a small rebase.How Has This Been Tested?
tests/unit/test_borg_argv.py, 127 tests. The Borg 1 pins (exact argv per job, including view-level check with a selected archive and the Borg 1 mount parser) were written first and pass against the unmodified code; they were not edited afterwards.prepare()output of all 16 job types was compared between the base commit and this branch under Borg 1.1.18, 1.2.8 and 1.4.3 with a range of archive names, prefixes and extra arguments: 825 entries, no differences.re.matchwith\Zappended); the mount parser is tested on Vorta's own command shapes, long and joined forms, foreign options and patterns, and truncated lines; a round trip feedsBorgMountJob.prepareoutput back into the parser.uv run pytest tests/unit --ignore=tests/unit/test_keyring_darwin.pyon macOS with Borg 1.4.5 on PATH: 491 passed, 7 skipped. The 5 warnings are the existingPytestUnhandledThreadExceptionWarnings fromtest_archives.pyandtest_lock.py, which also occur on master.Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.