839 Commits
Author SHA1 Message Date
Julio López e8c18a83f0 refactor(cli): repository upgrade actions and checks (#5714)
- check all mismatched fields in a content info
- change return type to `error` for `CheckIndexInfo`
- log errors as soon as they are detected, instead of accumulating them in memory
- refactor `drainAllClients`

Also:
- unexport `cli.checkIndexInfo`
- reduce `err` scope
- separate matching vs non-matching tests
2026-10-14 09:29:48 -07:00
Julio López bc517ac0d2 fix(cli): check for error while getting upgrade lock status (#5713) 2026-10-13 20:12:23 -07:00
Julio López 69fa1b2fae fix(cli): actually return an error when index validation fails (#5710) 2026-10-13 12:31:42 -07:00
Julio López 56ff291062 build(deps): upgrade to Go 1.27 (#5681)
- fix brittle TestBuildFromExtraError
- remove unused imports
- lint: modernize
- modernize: strings.CutLast
- simplify prefixSuffix
- fix tests due to changes in compress/flate implementation
- upgrade checklocks

- ref: https://go.dev/doc/go1.27#compressflatepkgcompressflate
2026-10-12 18:36:38 -07:00
Julio López 9b3243ead4 build(deps-dev): upgrade golangci-lint (#5673)
- upgrade golangci-lint to 2.14.0
- upgrade gomodguard_v2 config
- update gomodguard_v2 configuration to include aws-sdk-go-v2
- enable exhaustive linter on maps with explicit enforce annotation
- remove no-longer needed linter annotations
- gofumpt files, including tests
- enable gofumpt.extra.balance-calls
- gofumpt.extra.balance-calls
- add linter annotations as needed
- unexport newFormatBlobCache
- nit: use testingT interface
2026-10-02 17:22:06 -07:00
Julio López 5d3d878117 chore(testing): envflag.Bool helpers (#5665)
- add envflag.Bool() helper and tests
- use envflag in testing packages and tests
- use envflag for runtime settings
2026-09-26 21:08:52 -07:00
Julio López 0295aac97f refactor(testing): check for Scan() errors in CLITest env (#5626)
- Track return error with errgroup.
- Check for ctx error  in scan loop.
- Drain reader streams on error to prevent deadlock.
- Check stderr scanning error after starting async stderr draining.

- Disconnect repo before test context is cancelled.
  Defer instead of t.Cleanup in test. Needed to preserve
  the cleanup order relative to repo disconnect.
2026-09-16 21:41:38 -07:00
Julio López 9b964a7993 refactor(testing): server control tests (#5642)
Avoid calling `RunAndProcessStderr` in a background goroutine in tests.
Refactor TestServerControl and TestServerControlUDS.
Simplifies tests by removing unnecessary async processing.
Improves test cleanup.

- Required for #5626
2026-09-15 16:47:08 -07:00
Vetea edcd1171a4 fix(cli): mark snapshot verify --parallel as deprecated and no-op (#5552)
`--parallel` has had no effect on `snapshot verify` since #1921, which
merged the tree-walk and file-verification parallelism into the single
`VerifierOptions.Parallelism` field and wired it to `--file-parallelism`.
`verifyCommandParallel` has had no reader since then: the flag parses,
advertises a default of 8, and is silently discarded.

The Consistency documentation page still recommends `--parallel=10` in
four places, so users following it believe they are tuning something.

Follow the existing convention in this file for `--all-sources`: hide the
flag, label it as having no effect, and log a deprecation message when it
is passed. Dropping `Default("8")` lets the zero value distinguish an
explicit `--parallel` from an absent one, and stops the help text from
advertising a default that does nothing. The flag still parses, so
existing scripts and cron jobs keep working.

Restoring a separate tree-walk parallelism knob would be the alternative
fix, but that changes the public `snapshotfs.VerifierOptions` surface.
2026-09-10 14:07:07 -07:00
John Costa b16302dca9 fix(cli): reject negative values for --parallel flags (#5484)
The --parallel flag was declared with kingpin .IntVar on 12 commands,
which accepted negative values and led to a panic at runtime (e.g.
`snapshot migrate --parallel=-1`).

Declare the --parallel family as uint so kingpin rejects negative input
at parse time.
The uint->int conversion the callee APIs need is done through a small
helper .

Add CLI test that asserts the rejection message (a bare failure check passed
even without the fix since the commands also fail with no repository connected).
Parse via ParseFloat like kingpin's built-in int flag so the only behavior
change is rejecting negatives.
2026-09-09 20:07:17 -07:00
Aditya Raj Singh 2602713af4 fix(cli): report invalid log levels for maintenance runs (#5586)
- Fixes #4008
2026-09-09 16:30:06 -07:00
Julio López fdf0159a17 refactor(general): cleanup various nits (#5618)
- use struct field initialization idiom
- clarify error message
- directly use s.rootctx in server request processing
- refactor: use require in e2e ACL test
- inline constant definition
- modernize with `strings.Cut`
- modernize with slices.Backward
- simplify timeFormat initialization
- refactor testing: check `Scanner.Err()` in testenv
- remove spurious parenthesis
- trueStr and falseStr consts
- use inheritPolicyString
- use const in cache info
- "bytes" const in ui task counters
- use common consts in gettool
2026-09-06 15:08:49 -07:00
Julio López 9473eef9d1 build(deps-dev): upgrade golangci-lint to v2.11.4 (#5247)
Fixes for new linter warnings:
- fix: add //nolint annotations where it makes sense
- fix: remove no-longer necessary linter annotations
- fix linter: add or remove new lines
- fix linter: use Fprintf instead of WriteString
- fix: check for overflow in conversion to uint8 / byte
2026-09-03 12:12:20 -07:00
Julio López 3877e3714b refactor(cli): cleanup auto-maintenance run*Action helpers (#5482)
- remove no longer needed `repositoryAccessMode` struct
- pulls up auto-maintenance run check to the call path
  where it is actually used, after write session flushes to
  keep existing behavior
- nit: put nil check inside function
2026-07-09 09:49:35 -07:00
maximilizeandmax 6c65de1176 fix(cli): only run automatic maintenance after data-modifying operations (#5473)
* fix(cli): only run automatic maintenance after data-modifying operations

Automatic maintenance previously ran after any successful repository-writer
command, including control-only operations such as `policy set`, `acl ...` and
`user ...`. Make repositoryWriterAction skip maintenance by default and add
repositoryWriterActionWithMaintenance, used only by data-modifying commands
(snapshot create/delete/expire/migrate/fix-*/copy-move-history/pin,
manifest delete).

Fixes #3174

* fix(cli): treat snapshot pin and manifest delete as control-only

Per review, move both to repositoryWriterAction so they no longer trigger
opportunistic automatic maintenance. pin orphans no content and manifest
delete is a low-level operation not meant for direct use; any content it
orphans is reclaimed at the next scheduled maintenance.

---------

Co-authored-by: max <max@example.com>
2026-07-08 19:56:58 -07:00
Julio López 116ec249c2 chore(general): remove unused deprecated field (#5476)
- remove unused field `encryptorInfo.deprecated`
- simplify implementations and function signatures
- deprecate `--deprecated` CLI flag
2026-07-06 21:59:15 -07:00
Julio López b048b22daf refactor(general): cleanup iomem hints (#5439)
- rename package to iomem
- update comments
- unexport `directoryWithOptions`
- check for `Close()` error on test cleanup
- reword flag description
- wrap errors to facilitate troubleshooting
- update logging message
2026-06-26 22:07:01 -07:00
Julio López d886957c7d feat(snapshots): reduce kernel page-cache pressure during snapshots (#5437)
Add fadvise hints to backup read path to reduce OS cache pollution

Issue FADV_SEQUENTIAL at open and FADV_DONTNEED at close for every file read during backup. This tells the kernel to read-ahead aggressively and then reclaim pages once the file is fully consumed, reducing cache pressure from large backups without adding measurable overhead.

Uses SyscallConn().Control() instead of os.File.Fd() to avoid switching file descriptors to blocking mode, which would remove them from Go's epoll poller and stall the upload pipeline.

Incremental FADV_DONTNEED during reads was tested and removed — it adds ~15% overhead on large-file workloads by fighting the kernel's own LRU. Restore write-path cache eviction was also tested and not included.

Authored-by: Rajat Gupta rajat.gupta@veeam.com
2026-06-26 19:29:13 -07:00
Julio López 8b13419327 refactor(providers): no_extra_providers build tag (#5375) 2026-05-14 07:23:32 -07:00
c26c6a1b97 feat(cli): restrict insecure unauthenticated server to loopback binds (#5354)
* feat(cli): restrict insecure unauthenticated server to loopback binds

Reject starting the server with --insecure and --without-password when
--address would bind outside loopback (including empty host / all
interfaces). Validate the actual listener after Listen so systemd socket
activation cannot bypass the check.

Add hidden --allow-extremely-dangerous-unauthenticated-server-on-the-network
to opt into the previous behavior for isolated environments.

Extract validation into internal/insecureserverbind with table-driven tests.
Add end-to-end smoke tests for rejection and escape hatch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Update internal/insecureserverbind/insecureserverbind.go

Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>

* pr feedback

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2026-05-04 19:51:20 -07:00
Julio López 6d25951811 refactor(cli): registration mechanism for storage providers (#5350) 2026-04-30 08:25:04 -07:00
Julio López eee59b0e3c chore(providers): warn messages for extra storage providers (#5324)
Add warnings for unsupported, not actively tested and not maintained providers
2026-04-19 22:30:58 -07:00
Julio López c8b8fe1c7f refactor(general): bigmapbench profiling (#5321)
- improve bigmapbench stats output
- refactor bigmapbench profiling and remove unneeded dependency
- nit: unexport const
2026-04-18 12:00:47 -07:00
Julio López d1e5c1d8a0 chore(general): clean nits (#5313)
- make benchmarking params uint
- prevent error in compression benchmarking
- lint on Windows and address linter warnings
- upgrade golang.org/x/exp
- upgrade github.com/cncf/xds/go
- upgrade github.com/dustinkirkland/golang-petname
- direct users to forum
- add warning about _recovery recipes_
2026-04-16 21:41:39 -07:00
Julio López 09542631c2 fix(cli): hash benchmarking count (#5312)
Ref:

- #4181
- #4199
2026-04-16 16:21:34 -07:00
Julio López 40e645e11c refactor(cli): leverage x/term.IsTerminal (#5308) 2026-04-13 19:17:55 -07:00
Julio López 0661f65703 chore(cli): handle potential conversion overflow when setting progress default (#5271) 2026-04-06 21:38:59 -07:00
Julio López 29d4118aac refactor(general): address potential conversion overflows (#5266)
Minor robustness improvements

- add safety check when converting file descriptor (`os.File.Fd()`) to `int`
- check that file descriptor returned by Open (on Linux) is non-negative before converting to `uintptr`. This addresses a linter warning for a most-likely-non-existent-edge-case of converting a negative file descriptor.
- check that parsed content IDs (hashes) do not exceed the maximum id hash length.
- add nolint annotation for safe conversion
2026-04-01 21:51:44 -07:00
Julio López d1bc68ef61 refactor(general): cleanup nits (#5236)
Cleanup nits:
- get error handling policy upfront and improve readability in uploader
- update error message
- update field documentation and update flag description
- remove unused function
- const `isWindows` and remove redundant condition check
- add `getEnvVarBool` helper
- refactor common helper for mockfs.AddError* functions, and
  add mockfs.AddErrorEntry<Type> wrappers for clarity.
- removed list of skipped tests from gotestsum summary
2026-03-23 11:52:29 -07:00
Preston Hunt 71e35d773f feat(snapshot): disable progress by default if no tty (#5066)
When running without a tty, disable progress by default. The progress
includes binary characters such as a spinner that do not display
properly without a tty.
2026-02-06 19:45:26 -08:00
Julio López 39fb62970f refactor(cli): refactor diagnosis flags (#5026)
Refactor `--profile-*` flags:
- Multiple profile types can be enabled at once, before only
  a single type profiling could be done during a process execution.
- The new `--profiles-store-on-exit` enables all available profile
  types, except for CPU profiling which needs to be explicitly enabled.
- Profiling parameters can now be set via new flags. This allows setting
  the profile parameters for the pprof endpoint, as well as when saving
  profiles to files on exit.
- Group profiling flags with other observability flags
- Adds a `--diagnostics-output-directory` flag that unifies and
  supersedes the `--profile-dir` and `--metrics-directory` flags

Enhancements and behavior changes:
- Profile flags now have effect for all kopia commands, including
  `server start`. Before these flags did not have any effect
  in a few commands.
- Multiple profile types can be enabled at once, before only
  a single type profiling could be done during a process execution.
- The new `--profiles-store-on-exit` enables all available profile
  types, except for CPU profiling which needs to be explicitly enabled.
- Profiling parameters can now be set via new flags. This allows setting
  the profile parameters for the pprof endpoint, as well as when saving
  profiles to files on exit.

The following flags have been removed:
- `--profile-dir`: superseded by the `--diagnostics-output-directory` flag
- `--profile-blocking`: the `--profile-store-on-exit` flag enables blocking
  profiling. Use `--profile-blocking-rate=0` to explicitly disable it.
- `--profile-memory`: the `--profile-store-on-exit` flag enables memory
  profiling. Use `--profile-memory-rate=0` to explicitly disable it.
- `--profile-mutex`: the `--profile-store-on-exit` flag enables mutex
  profiling. Use `--profile-mutex-fraction=0` to explicitly disable it.

Add CLI test for profile flags.
2025-11-26 09:40:01 -08:00
Nathan Baulch ea1bdb1541 chore(ci): enable noctx linter (#4972)
* pass context in webdav helpers
* fix typo in function name
2025-11-19 21:46:28 -08:00
Julio Lopez 7db061ee71 build(deps): Go 1.25 (#4987)
Upgrade to Go 1.25
Leverage `WaitGroup.Go` in Go 1.25
2025-11-17 16:42:12 -08:00
Julio Lopez 70f8d678d0 fix(general): handle errors closing writable descriptors (#4998) 2025-11-16 23:07:51 -08:00
Julio Lopez 070c15b888 chore(general): avoid wrapping always-nil error (#4997) 2025-11-16 22:55:35 -08:00
Julio Lopez db4b89bc3d fix(cli): potential overflow in integer conversion (#4993) 2025-11-15 22:36:45 -08:00
lyndon-li c3c971a785 feat(general): fix display errors for maintenance stats (#4984) 2025-11-13 12:27:42 -08:00
Julio Lopez bb20d9e11a chore(ci): enable wsl_v5:{assign,expr} linter settings (#4982)
Enable wsl_v5 settings:
- assign
- expr
2025-11-12 23:12:06 -08:00
Julio Lopez 80eda18f99 chore(ci): enable wsl_v5:err linter (#4928) 2025-11-12 22:15:27 -08:00
lyndon-li 157c80e5e7 feat(snapshots): Flush after restoring each file (#4825)
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
2025-11-12 20:59:56 -08:00
Nathan Baulch 657fda216a chore(ci): upgrade to golangci-lint 2.6.1 (#4973)
- upgrade to golangci-lint 2.6.1
- updates for gosec
- updates for govet
- updates for perfsprint
- updates modernize

Leaves out modernize:omitempty due to conflicts with tests
2025-11-11 21:27:10 -08:00
Julio Lopez 19af93f2b1 refactor(ci): enable wsl_v5:return linter (#4975)
Also, disable redundant nakedret linter
2025-11-11 16:53:10 -08:00
Nathan BaulchandJulio Lopez 557940c524 chore(ci): upgrade to golangci-lint v2.5.0 (#4931)
Upgrades golangci-lint to v2.5.0

Enables:
- wsl_v5

Disables:
- embeddedstructfieldcheck
- noinlineerr (not used in this codebase)
- noctx (temporarily)
- godot
- wsl (deprecated)

Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2025-11-11 12:37:07 -08:00
lyndon-li 3b7f193c29 feature(general): maintenance stats for rewrite contents phase (#4961) 2025-11-06 10:22:58 -08:00
lyndon-li 3446837bed feat(general): maintenance stats for clean up logs phase (#4959) 2025-11-05 23:23:47 -08:00
Julio Lopez c7ea2c6e09 refactor(general): consistent use "pack" where possible (#4952)
In kopia, "blob" is a generic term to refer to either
an object in an object storage provider, or a file
in a file system storage provider. There are various
types of blobs in a kopia repository.

In kopia, the term "pack" is used to refer to specific types
of blobs, namely 'p' & 'q' pack blobs, that store
"content" data, as opposed to say, "index" blobs.

This change attempts to use the term "pack" consistently
in the functions and types used for pack deletion.

Note that the corresponding task names, shown below, remain
unchanged since these names are used in the persistent
maintenance run metadata, and that is used to make decisions
about the safety of the execution of those tasks.

```
	TaskDeleteOrphanedBlobsQuick     = "quick-delete-blobs"
	TaskDeleteOrphanedBlobsFull      = "full-delete-blobs"
```
2025-11-05 22:03:21 -08:00
lyndon-li db48fad95e feat(general): maintenance stats for delete unreferenced packs phase (#4955) 2025-11-04 22:51:17 -08:00
lyndon-li 83bd4d45da feat(general): maintenance stats for drop deleted contents and compact indexes (#4948) 2025-11-04 11:40:20 -08:00
Julio Lopez 356930b1a9 refactor(general): simplify function and generics signatures (#4930) 2025-10-29 12:32:51 -07:00
Julio Lopez 995e7fd893 refactor(general): modernize (#4903)
Applies the modernize changes for the following categories:

- mapsloop
- stringsseq
- stringscutprefix
- sortslice
2025-10-23 17:11:38 -07:00