Commit Graph

356 Commits

Author SHA1 Message Date
Aaron Alpar
f3a621dbf8 bug(test): Fixup error output when server startup fails in robustness test (#3462)
* add logging to failed server start

* fixup for lint
2023-11-22 22:24:17 +00:00
Jarek Kowalski
3eff91a49b fix(ui): Fixing colors in dark theme (#3392)
* fix(ui): Fixing colors in dark theme

* fixed test

* pickup latest htmluibuild
2023-10-17 22:33:54 -07:00
Jarek Kowalski
7ee30b76bb fix(repository): fixed handling of content.Info (#3356)
* fix(repository): fixed handling of content.Info

Previously content.Info was an interface which was implemented by:

* index.InfoStruct
* index.indexEntryInfoV1
* index.indexEntryInfoV2

The last 2 implementations were relying on memory-mapped files
which in rare cases could be closed while Kopia was still processing
them leading to #2599.

This changes fixes the bug and strictly separates content.Info (which
is now always a struct) from the other two (which were renamed as
index.InfoReader and only used inside repo/content/...).

In addition to being safer, this _should_ reduce memory allocations.

* reduce the size of content.Info with proper alignment.

* pr feedback

* renamed index.InfoStruct to index.Info
2023-10-14 10:34:15 -07:00
PhracturedBlue
0f608ff18c test(cli): Attempt to fix socket-activated tests (#3318) 2023-09-18 21:47:39 -07:00
Jarek Kowalski
af1550ad81 feat(server): reduce server refreshes of the repository (#3265)
* feat(server): reduce server refreshes of the repository

Previously each source would refresh itself from the repository
very frequently to determine the upcoming snapshot time. This change
refactors source manager so it does not own the repository connection
on its own but instead delegates all policy reads through the server.

Also introduces a new server scheduler that is responsible for
centrally managing the snapshot schedule and triggering snapshots
when they are due.

* Update cli/command_server_start.go

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

* Update internal/server/server.go

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

* Update internal/server/server_maintenance.go

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

* pr feedback

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2023-09-15 12:08:35 -07:00
Jarek Kowalski
044db7593b feat(repository): apply retention policies server-side (#3249)
* feat(repository): apply retention policies server-side

This allows append-only snapshots where the client can never delete
arbitrary manifests and policies are maintained on the server.

The client only needs permissions to create snapshots in a given, which
automatically gives them permission to invoke the server-side method
for their own snapshots only.

* Update cli/command_acl_add.go

Co-authored-by: Guillaume <Gui13@users.noreply.github.com>

* Update internal/server/api_manifest.go

Co-authored-by: Guillaume <Gui13@users.noreply.github.com>

* Update internal/server/api_manifest.go

Co-authored-by: Guillaume <Gui13@users.noreply.github.com>

* Update internal/server/grpc_session.go

Co-authored-by: Guillaume <Gui13@users.noreply.github.com>

---------

Co-authored-by: Guillaume <Gui13@users.noreply.github.com>
2023-09-02 18:23:21 -07:00
Julio Lopez
1320f0c8e8 chore(general): remove unnecessary //nolint directives (#3256) 2023-08-29 12:40:40 -07:00
Jarek Kowalski
fe55dcb6a2 feat(repository): added hard size limit to the on-disk cache (#3238)
* test(providers): added capacity limits to blobtesting.mapStorage

* refactor(general): added mutex map which dynamically allocates and releases named mutexes

* refactor(repository): refactored cache cleanup and limit enforcement

* refactor(repository): plumb through cache size limits in the repository

* feat(cli): added CLI options to set cache size limits

* unified flag setting and field naming

* Update cli/command_cache_set.go

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

* pr feedback

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2023-08-24 09:38:56 -07:00
NickIAm
a9c5a993c8 fix(cli): prevent duplicate snapshots when --all and a source path are given (#3067)
Adds a check for snapshot create when --all and a source path are
given simultaneously. Returns an error in this case since it would
otherwise create a  duplicate snapshot for the specified source path.

---

Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2023-08-03 17:36:10 +00:00
Minyi Zou
a620349db8 test(general): add crash consistency test to validate repository consistency when kopia stops abruptly (#3142)
* test(general): add tests for crash consistency in robustness feature

* test(general): add GenerateRandomFiles function

* test(general): rename tests for crash consistency in robustness feature

* Update tests/recovery/blobmanipulator/blobmanipulator.go

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

* Update tests/robustness/crash_consistency_test/crash_consistency_test.go

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

* test(general): add tool for crash consistency job for automatic test

* test(general): fix mistakes followed by comments

* test(general): modify Makefile with new tests

* test(general): delete absolute path

* test(general): crash consistency job make target change

* test: test in server

* test: set as local dir

* test: print log

* test: update dst path

* test(general): refactor test cases and tools

* test(general): reduce unused code

* test(general): fix bug

* test: append logs for testing

* test: remove deleted blob code

* test: handle cannot open issue

* test: remove kopia password relevant code

* test: add numbers of test and set parallel in test case

* test: block goroutine

* test: add test files

* test: refactor test tools

* test: add filter

* test: refactor file structure

* test: remove unused test job and relocate the filehandler

* test: fix error

* test: fix followed by comments

* fix: fix go lint problems

* Update tests/recovery/recovery_test/recovery_test.go

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

* fix: fix error followed by comments

* chore: don't change previous code

* chore: don't change previous code

* test: remove unused stdoutpipe

* no error print for kill -9 case

* Instead of writing your own comparison, you can use the directory comparator from the Kopia's internal diff module

* remove mu and err out

* remove error code

* Update tests/recovery/blobmanipulator/blobmanipulator.go

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

* remove useless code

---------

Co-authored-by: Minyi Zou <minyi.zou@kasten.io>
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
Co-authored-by: chaitalisg <chaitali@kasten.io>
2023-08-02 15:54:14 -07:00
Jarek Kowalski
83b88d8bbf chore(ci): fixes for ARM64 runner on AWS (#3179)
- fixed directory iteration order
- reduced providervalidation memory usage
- disabled one test case of TestSnapshotSparseRestore
  (filed https://github.com/kopia/kopia/issues/3178 to fix)
2023-07-27 11:30:40 -07:00
Christoph Anderson
90985b972e fix(ci): add test for theme selection (#3157)
* - Added test for changing themes
- Encapsulated the creation of a test repository in a function
- Added test for changing the byte representation
- Added test for changing the pagination

* - Fixed byte representation test

* - Fixed lint

* - Another lint fix

---------

Co-authored-by: lupusA <lupuapps@gmail.com>
2023-07-20 19:44:00 -07:00
Julio Lopez
d97679608e fix(cli): preserve error exit code when '--json' output is specified (#3163)
Changes kopia's behavior to match the exit code that would
have been returned when the `--json` flag was not specified.

`kopia snapshot create my/path --json` terminates with a 0
status code in cases where
`kopia snapshot create my/path` terminates with a
 non-zero exit code.

One such case is when there are permissions errors reading
files or directories to snapshot.

Adds end-to-end tests for snapshot create with '--json' flag
2023-07-20 06:39:40 -07:00
Jarek Kowalski
d8a33bdd44 feat(ui): UI updates (Theming support, action fix) (#3145)
* feat(ui): UI updates (Theming support, action fix)

- theming support https://github.com/kopia/htmlui/pull/150
- actions fix https://github.com/kopia/htmlui/pull/163

* disable dark mode selector test
2023-07-13 21:36:08 -07:00
Maxim Schuwalow
851fe6c193 feat(cli): add --override-source parameter to allow overriding source when snapshotting (#3041) 2023-07-11 17:34:30 -07:00
chaitalisg
d2ddda7114 test(general): Handle no space left errors in robustness tests (#3043)
* Handle no space left errors in robustness tests

* fix lint error
2023-06-20 16:33:55 +00:00
Jarek Kowalski
cbc66f936d chore(ci): upgraded linter to 1.53.3 (#3079)
* chore(ci): upgraded linter to 1.53.3

This flagged a bunch of unused parameters, so the PR is larger than
usual, but 99% mechanical.

* separate lint CI task

* run Lint in separate CI
2023-06-18 13:26:01 -07:00
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