Commit Graph

339 Commits

Author SHA1 Message Date
Jarek Kowalski
2568eebc6e chore(general): fixed remaining checklocks violations (#2939)
We can't enable checklocks on CI yet until
https://github.com/google/gvisor/pull/8807 is merged upstream.

This was tested with private build of checklocks with this patch
applied and the results were clean.
2023-04-13 20:11:36 -07:00
Julio Lopez
8f2499b94b breaking(cli): remove deprecated 'snapshot gc' command (#2862)
* remove deprecated `snapshot gc` command
* run `maintenance` instead of `snapshot gc` in robustness
* use `maintenance` command instead of `gc` alias for clarity
* use `maintenance run` in `TestSnapshotDeleteRestore`
2023-04-10 23:17:32 -04:00
Julio Lopez
9a9048c121 breaking(cli): remove default behavior for CLI command (#2861)
* breaking(cli): remove default behavior for `snapshot` command

command: snapshot
default-subcommand: create

* breaking(cli): remove default behavior for `cache` command

command: cache
default-subcommand: info

* breaking(cli): remove default behavior for `index` command

command: index
default-subcommand: list

* breaking(cli): remove default behavior for `maintenance` command

command: maintenance
default-subcommand: run

* breaking(cli): remove default behavior for `manifest` command

command: manifest
default-subcommand: list

* breaking(cli): remove default behavior for `repository upgrade` command

command: repository upgrade
default-subcommand: begin

* breaking(cli): remove default behavior for `server` command

command: server
default-subcommand: start
2023-04-09 01:34:36 +00:00
Julio Lopez
f89fe39927 chore(robustness): use zero value for strings.Builder (#2863) 2023-03-28 09:46:29 -07:00
Julio Lopez
a99e38c247 fix(lint): remove uses of deprecated rand.Read (#2858)
Lint fixes in preparation for moving to Go 1.20

Remove deprecated calls to `rand.Seed`
In Go 1.20 the default generator is seeded randomly at program startup,
which is the desired behavior for these tests.

Remove uses of deprecated rand.Read: replace with calls to rand.Uint64()

Remove deprecated uses of rand.Read in content manager tests and
S3 versioned tests.
Adds a concurrency-safe helpers to provide functionality similar to that
provided by `rand.Read(b []byte) (int, error)`
2023-03-28 01:44:09 +00:00
Aaron Alpar
c65613ccba feat(cli): ability to read repository status ... (#2799)
* fix spelling

* permissive index read

* fixup v1 permissive index

* fixups for lint

* trigger rebuild

* Update repo/local_config.go

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

* rename permissive read flag

* extend "permissive-read" rename

* hide permissive command-line flag

* syntax fixup

* fixup for test

* fixups for tests

* Update .golangci.yml

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2023-03-27 16:08:11 -07:00
Jarek Kowalski
07972b56cf fix(ci): fixed test race condition due to logging (#2852) 2023-03-26 17:05:12 -07:00
Jarek Kowalski
6fa50640f4 build(deps): manual upgrade to github.com/alecthomas/kingpin/v2 (#2804)
also upgraded github.com/klauspost/reedsolomon to latest non-retracted version
go mod tidy
2023-03-11 06:28:05 -08:00
Julio Lopez
5c901abc90 test(general): parse stdout and stderr in robustness framework helper (#2779)
Parse stdout as well as stderr in `KopiaSnapshotter.CreateSnapshot`.
This is contained to the Robustness Framework.

Co-authored-by: Carl Braganza <carl@kasten.io>
2023-02-23 10:18:07 -08:00
Jarek Kowalski
ba919e9f16 chore(ci): fixed test flakes caused by not waiting for server to stop (#2749) 2023-02-09 06:46:56 +00:00
Jarek Kowalski
2801ab1640 feat(repository): added streaming of FindManifests responses (#2733)
This change adds a new streaming response to the FindManifests API. The
server will deliver the response in chunks of N manifests where N is
requested by the client. This allows the client to process the response
in chunks and improves pipelining of responses.

For now client will hold the entire response in memory since this
is what FindManifests() API currently does. This will be fixed in a
follow up change.

Replaces #2713
Fixes #2660
2023-02-07 06:19:09 -08:00
Jarek Kowalski
e6612977b7 feat(server): improved server shutdown and integration tests (#2722)
* feat(server): improved server shutdown and integration tests

Added `--shutdown-grace-period` flag to `kopia server start` command
which can be used to specify how long the server will wait for active
connections to finish before forcibly shutting down.

This allowed removal of final out-of-process execution of
during integration tests and the need for `integration-tests` target
which was running the same tests as `tests` but in out-of-process mode.

We thus now have all the test coverage in-process without having to
build and launch `kopia` binary.

* fixed logging

* increase test timeout

* speed up and/or parallelize longest-running tests
2023-02-01 22:19:32 -08:00
ashmrtn
fba94ff61e feat(snapshots): Return ReadCloser from StreamingFiles (#2692)
* Return ReadCloser from StreamingFile

Allow better resource management by returning something that can be closed
when dealing with StreamingFiles.

* Close StreamingFile Reader during upload

* Use NopCloser on inputs that don't implement Close

Fixup callers of the StreamingFile API by wrapping regular Readers with
NopCloser calls where necessary.
2023-01-21 16:02:57 +00:00
Edward Betts
1e97574391 fix(general): correct spelling mistakes (#2684) 2023-01-21 07:37:15 -08:00
Jarek Kowalski
f8be8f6a56 refactor(repository): extract parts repo/content into packages (#2651)
- repolog package
- blobcrypto package
- indexblob package

Minor cleanups:

- removed dead code
- introduced New*() methods for object construction
2022-12-17 16:19:12 +00:00
Aaron Alpar
4c0fe390e1 feat(repository): new repository upgrade sub-command to validate indices. (#2561)
* remove unused context param

* add index validation

* add test

* add command stub

* add comments. fixup.

* Update cli/command_repository_upgrade.go

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

* fixup bad merge

* add validation to command line

* set-parameter fixup

* move poison blob to commit

* fixups from PR comments

* fix bug for set-parameter

* robust commit-mode. add upgrade test

* fixup incorrect methods

* fixup for lint

* fixup for lint

* fixup named return values

* fixup failing test

* fixup lint

* fixup for lint

* Update repo/content/committed_read_manager.go

Co-authored-by: Nick <nick@kasten.io>

* Update repo/content/committed_read_manager.go

Co-authored-by: Nick <nick@kasten.io>

* use xor instead of fixed value

* lint fixups

* fixup for lint cyclomatic complexity

* fixup bad merge

* fixup set-parameters downgrade

* Update cli/command_repository_upgrade.go

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

* Update cli/command_repository_upgrade.go

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

* fixup set-parameters downgrade

* cleanup set-parameters test

* fixup tests, refactor for index verification

* fixups and clarity

* remove set-parameter downgrade check

* index on feat-k10-12441-B-validate-index: b63879cd Merge 'master' into feat-k10-12441-B-validate-index

* trigger build

* remove needless blank line

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
Co-authored-by: Nick <nick@kasten.io>
2022-12-13 09:42:09 -08:00
lciti
37d64afc21 fix(snapshots): Partly fix #544 by supporting setuid/setgid/sticky bits when snapshotting, restoring and fuse-mounting. (#2597)
Also modified an end-to-end test to also check that these extra mode flags work when snapshotting+restoring.
Manually tested fuse-mount.

Co-authored-by: Luca Citi <lciti@ieee.org>
2022-12-07 03:26:29 +00:00
Jarek Kowalski
e57020fb70 test(repository): server testability refactoring (#2612)
- removed repo.OpenAPIServer() which was only needed for testability
- introduced servertesting package to replace it
2022-12-01 06:27:52 +00:00
Jarek Kowalski
65f295ed79 refactor(repository): replaced atomic values with Go 1.19 atomic wrappers (#2590)
Almost all were easy to replace, except ones exposed via JSON which
have been left as-is.

The linter has a cool behavior where it flags attempts to pass
`atomic.Int32` for example by value , which is always a mistake,
say as an argument to `fmt.Sprintf()`
2022-11-19 18:39:04 +00:00
Jarek Kowalski
d782dbe550 refactor(repository): refactored Repository close logic (#2589)
This ensures metric registry is always closed on last Close().
2022-11-19 06:52:03 +00:00
Jarek Kowalski
0554e2f7ce refactor(general): introduced generics to reduce boilerplate code (#2527)
This removes tons of boilerplate code around:

- retry loop
- connection management
- storage registration

* used generics in runInParallel
* introduced generics in freepool
* introduced strong typing for workshare.Pool and workshare.AsyncGroup
* fixed linter error on openbsd
2022-10-29 01:56:51 +00:00
Jarek Kowalski
f69424961f chore(ci): upgrade golang to 1.19.2 and linter to 1.50.1 (#2526)
Lack of generics support is blocking various dependency upgrades,
so this unblocks that.

Temporarily disabled `checklocks` linter until it is fixed upstream.
2022-10-28 11:02:47 -07:00
atom
c5efed01f4 feat(cli): Support displaying storage values in base-2 [#2492] (#2502)
* Update display on repository summary

* Apply throughout app

* Situate units_test

* Update Command Line documentation

* Envar cleanup

* Rename to BytesString

* Restore envar string available for test

* Remove extraneous empty check and restore UIPreferences field for frontend

* PR: config bool cleanup and missed `BaseEnv`s

* Fix lint and test
2022-10-24 19:00:36 -07:00
Jarek Kowalski
c1be8c4750 fix(repository): fixed frequent repository refreshes for older repositories (#2468)
This is a regression in 0.12.0 and was reported on Slack by
Amir Zarrinkafsh.

Repository connections made using old version of Kopia did not properly
save format blob cache duration so it was defaulting to 0s instead of
15 minutes causing endless format refreshes, slowing things down and
causing unnecessary read traffic to blob storage.
2022-10-01 13:31:50 -07:00
Aaron Alpar
02ecd0d5a7 feat(repository): Allow clock drift to be specified on upgrade. (#2357)
* add max-clock-drift flag

* fixups

* module dependencies

* package fixup
2022-09-26 18:28:56 -07:00
chaitalisg
b626f148ee test(general): Use new kopia upgrade cli in robustness upgrade tests (#2355)
* Use new kopia upgrade cli

* Clean up environement variable

* Clean up environement variable

* Clean up debugging change

* Fix lint errors

* Fix lint errors
2022-09-20 14:00:53 -07:00
Jarek Kowalski
09453d8ae9 fix(ci): fixed the root cause of the HTMLUI test flake (#2387) 2022-09-09 03:21:50 +00:00
Ali Dowair
3e5d61137a fix(ci): revert "skip TestS3Connect() until we fix the S3 regression" (#2380)
This reverts commit 7fbf863607.
2022-09-07 20:24:58 -07:00
Ricardo Pescuma Domenecci
31495392a1 feat(cli): Allow restore from snapshoted path (#2335)
* feat(cli): Allow restore from snapshoted path

* Find files in multiple snapshots

* Added --snapshot-time to restore

* Added restore by path test

* More timespec formats

* Test for snapshot list with a file in multiple snapshots

* Handle restore without target path

* Fix for tests

* Made changes requested in PR and rebased
2022-09-06 04:42:07 +00:00
chaitalisg
0ae4d63c61 test(general): Fix upgrade portion of robustness test (#2337)
* Move upgrade repository test function

* Delete test for deleted function

* Move upgrade repository test function

* Resolve conflicts

* Check for error in status function

* Add unit test
2022-08-29 10:57:37 -07:00
Jarek Kowalski
5ad8f1cf38 fix(ci): try to fix HTMLUI test flake (again) (#2326) 2022-08-19 09:33:52 -07:00
Ricardo Pescuma Domenecci
47aaa2dc40 feat(cli): Added ECC related options to repository create cli command (#2308)
* Encryptor pipeline

* Added ECC related options to repository create cli command

* Fix for lint errors

* Fixing comments from the PR

* Fixed lint errors

* Changes requested in PR

* Created e2e test
2022-08-13 08:49:22 -07:00
Jarek Kowalski
6097e1a21c fix(ci): another attempt to fix flaky HTMLUI test (#2298) 2022-08-10 02:05:02 +00:00
chaitalisg
b61a7627e9 test(general): Add test for snapshot fix command (#2018)
* add robustness test for snapshot fix commands

* temporary change to see if plumbing works

* add robustness test for snapshot fix commands

* temporary change to see if plumbing works

* debug

* revert changes to robustness main_test

* Move recovery tests to a new package

* Revert unwanted changes

* Updated make target

* Temporary change for a pipeline run

* Resolve go package issues

* Remove local path used for debugging

* Debugging

* Debugging

* Add new orchestration script for recovery test

* Add comments

* Add comments

* Revert changes to robustness job script

* Remove unawanted files

* Change permissions for the orchestration script

* Fix typo

* Executable

* Update orchestration script

* Fix linter errors

* Fix linter errors

* Fix linter errors

* fix: linter grouping issue

* Fix linter errors

* Fix linter errors

* Update tests/recovery/blobmanipulator/blobmanipulator.go

Co-authored-by: Aaron Alpar <55999015+aaron-kasten@users.noreply.github.com>

* Implement feedback

* Implement feedback

* Fix linter errors

* Address feedback

* Add maintenance functions

* Added mechanism to interrupt kopia operation during the test run

* Fix linter errors

* Revert debugging changes

* Fix linter errors

* Fix linter errors

* Replace syscall

* Skip test when KOPIA_EXE is not set

* Remove debugging changes

* Add kopia command interruption to simulate corruption

* Check if command is running before killing

* Delete a snapshot before calling maintenance

* Remove nil check for the process

Co-authored-by: Shikhar Mall <small@kopia.io>
Co-authored-by: Aaron Alpar <55999015+aaron-kasten@users.noreply.github.com>
2022-08-09 09:44:18 -07:00
Jarek Kowalski
51dcaa985d chore(ci): upgraded linter to 1.48.0 (#2294)
Mechanically fixed all issues, added `lint-fix` make target.
2022-08-09 06:07:54 +00:00
Jarek Kowalski
03159a1ff3 chore(ci): add logging to identify the cause of test flakes (#2287) 2022-08-07 09:56:14 -07:00
Jarek Kowalski
6160ee5668 refactor(repository): moved format blob management to separate package (#2245)
* refactor(repository): moved format blob management to separate package

This is completely mechanical, no behavior changes, only:

- moved types and functions to a new package
- adjusted visibility where needed
- added missing godoc
- renamed some identifiers to align with current usage
- mechanically converted some top-level functions into member functions
- fixed some mis-named variables

* refactor(repository): moved content.FormatingOptions to format.ContentFormat
2022-07-30 14:13:52 -07:00
Jarek Kowalski
a759e097f5 skip TestS3Connect() until we fix the S3 regression (#2246) 2022-07-28 22:35:43 -07:00
Jarek Kowalski
03da9b1f0e feat(cli): improved safety of v1->v2 index format upgrade (#2223)
When upgrading from legacy to epoch manager-based index, we will write
an intentionally-corrupted index blob, such that old clients won't be
able to understand it when they read the repository index using legacy
format.

The error message emitted by very old clients is not great, but it's
safer to do that rather than corrupt the repository.

Note that this additional safety has a delay of up to 15 minutes
which is the time required for old clients to stop relying on index list
cache in case of very long-running snapshots, server or KopiaUI.
2022-07-28 17:32:31 -07:00
Jarek Kowalski
56f3046d8a refactor(repository): introduce interface for reading FormattingOptions (#2235)
Instead of passing static content.FormattingOptions (and caching it)
we now introduce an interface to provide its values.

This will allow the values to dynamically change at runtime in the
future to support cases like live migration.
2022-07-28 17:27:04 -07:00
Shikhar Mall
26e6f59b2b feat(cli): New Upgrade CLI / Switch to Format Version 3 (upgrade coordination) (#1818)
* kopia format upgrade lock

* Update cli/command_repository_set_parameters_test.go

Co-authored-by: Ali Dowair <adowair@umich.edu>

* Update cli/command_repository_upgrade.go

Co-authored-by: Ali Dowair <adowair@umich.edu>

* Update cli/command_repository_upgrade.go

Co-authored-by: Ali Dowair <adowair@umich.edu>

* pr feedback

* pr feedback

* add a min drain time check

* env var for io-drain-timeout

* fix: add more doctext around upgrade phases

* build: wrap with EnvName

* add experimental warning

* protect upgrade cli behind env varible

* fix conflicts after relocating the upgrade lock

* generalize the command args

* drop certain features as per feedback

* sub-divide the upgrade command into begin and rollback

* Update cli/command_repository_upgrade.go

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

* Update cli/command_repository_upgrade.go

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

* missing return

* rename force flag to allow-unsafe-upgrade

Co-authored-by: Shikhar Mall <shikhar@kasten.io>
Co-authored-by: Ali Dowair <adowair@umich.edu>
Co-authored-by: Shikhar Mall <small@kopia.io>
Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2022-07-27 16:23:45 -07:00
Jarek Kowalski
1a82061e49 chore(ci): upgraded linter to 1.47.0, added 15s ReadHeaderTimeout in web server (#2206) 2022-07-18 22:47:36 -07:00
Jarek Kowalski
191b3e5461 feat(cli): BREAKING CHANGE ensure --checkpoint-interval is <=45min (#2196)
Also hide the flag, since it's not recommended to be tweaked anyway.

The value of <=45m is very important for safety of the garbage collection algorithms - too long an interval between checkpoints could mean that GC treats contents in the middle of being uploaded as unused, because they are not reachable from any snapshots or checkpoints.

Fixes #2193
2022-07-16 04:15:32 +00:00
Jarek Kowalski
8515d050e5 test(infra): improved support for in-process testing (#2169)
* feat(infra): improved support for in-process testing

* support for killing of a running server using simulated Ctrl-C
* support for overriding os.Stdin
* migrated many tests from the exe runner to in-process runner

* added required indirection when defining Envar() so we can later override it in tests

* refactored CLI runners by moving environment overrides to CLITestEnv
2022-07-09 18:22:50 -07:00
Jarek Kowalski
9941a05ab1 chore(ui): upgraded UI (#2157)
* https://github.com/kopia/htmlui/pull/88
* https://github.com/kopia/htmlui/pull/90
* https://github.com/kopia/htmlui/pull/89
* https://github.com/kopia/htmlui/pull/84
* https://github.com/kopia/htmlui/pull/85
2022-07-07 03:54:11 +00:00
Ali Dowair
98e10d52f1 Rename --sparse to --write-sparse-files (#2095)
This commit renames the sparse restore flag (`kopia snapshot restore`
and `kopia restore`) to conform more with the naming precedents in
the Kopia code. This is a breaking change.

The original motivation can be found here:
https://github.com/kopia/htmlui/pull/61#discussion_r899155054
2022-07-01 19:01:53 -07:00
Jarek Kowalski
70e24106ee refactor(general): unified logging.Logger with *zap.SugaredLogger (#2090)
- removed a bunch of hacks and should improve the logging
performance by avoiding interfaces and data translation. This will
allow using of de-sugared loggers in performance-critical
logging situations.

- this will also allow using features of ZAP more directly without
having to reimplement them.

- moved logging.Printf() to testlogging

- refactored `uitask` to store logs in a structural format and
present them as JSON only in the UI

- renamed printf_logger.go to printf.go so that fewer columns are used
in the logs
2022-06-26 05:11:52 +00:00
Ali Dowair
eddde91f2d chore(snapshots): unify sparse and normal FS output paths (#1981)
* Unify sparse and normal IO output

This commit refactors the code paths that excercise normal and sparse
writing of restored content. The goal is to expose sparsefile.Copy()
and iocopy.Copy() to be interchangeable, thereby allowing us to wrap
or transform their behavior more easily in the future.

* Introduce getStreamCopier()

* Pull ioCopy() into getStreamCopier()

* Fix small nit in E2E test

We should be getting the block size of the destination file, not
the source file.

* Call stat.GetBlockSize() once per FilesystemOutput

A tiny refactor to pull this call out of the generated stream copier,
as the block size should not change from one file to the next within
a restore entry.

NOTE: as a side effect, if block size could not be found (an error
is returned), we will return the default stream copier instead of
letting the sparse copier fail. A warning will be logged, but this
error will not cause the restore to fail; it will proceed silently.
2022-06-14 18:09:45 +00:00
basldfalksjdf
a78dacc0d1 feat(snapshots): add option to ignore empty snapshots being saved (#2036)
* Add policy to ignore empty snapshots being saved

* Update command_snapshot_create.go

* Update source_manager.go

* Update command_snapshot_create.go

* Update source_manager.go

* fixes

* Update source_manager.go

* Update command_snapshot_create.go

* fix

* fix

Co-authored-by: Mehak  Satija <mehaksatija@Mehaks-MacBook-Pro.local>
Co-authored-by: Mehak  Satija <mehaksatija@Mehaks-MBP.hitronhub.home>
2022-06-13 03:41:08 +00:00
ashmrtn
ef8828a072 refactor(snapshots): Remove remaining internal uses of Readdir (#1986)
* Remove remaining internal uses of Readdir

* Remove old helpers and interface functions.

* Update tests for updated fs.Directory interface

* Fix index out of range error in snapshot walker

Record one error if an error occurred and it's not limiting errors

* Use helper functions more; exit loops early

Follow up on reviewer comments and reduce code duplication, use more
targetted functions like Directory.Child, and exit directory iteration
early if possible.

* Remove fs.Entries type and unused functions

Leave some functions dealing with sorting and finding entries in fs
package. This retains tests for those functions while still allowing
mockfs to access them.

* Simplify function return
2022-06-04 06:36:25 -07:00