Commit Graph

389 Commits

Author SHA1 Message Date
chaitalisg
b3e088d66a test(general): log dir paths and size in robustness tests (#3973)
Log the paths and the sizes for the cache directories in
multi-client robustness jobs.
2024-07-19 22:58:23 -07:00
Julio López
b980d11c42 refactor(general): setCacheSizeHardLimit helper in robustness (#3990) 2024-07-18 23:59:58 -07:00
chaitalisg
b0814ee3ff fix(test): allow delete random snapshot action (#3987)
Addresses failure introduced in #3963

Change: allow `delete-random-snapID` action in the function `tryDeleteAction`.
Test: Manual local run was successful.
2024-07-16 13:25:24 -07:00
chaitalisg
de298566ea test(general): add delete random snapshot action to robustness tests (#3963)
---------
Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2024-07-15 19:35:25 -07:00
chaitalisg
00495c73ea test(general): set cache size limits for the repository under test used in robustness tests (#3945)
The robustness tests set soft limits for content cache size
and metadata cache size. This PR adds the hard limits for
both the caches, thus reducing the memory required to
run the robustness tests for long term.
2024-07-15 14:06:36 -07:00
chaitalisg
2ec9bbe43c test(general): set cache size limits for metadata repo (#3952)
The soft limits are set for content cache and metadata cache.
This may cause the cache to bloat beyond expectations.
Setting hard limits for the size would keep the cache bloat in
check, thus reducing the memory needed to required to run
the robustness tests over a long time.

---------

Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2024-07-15 13:50:55 -07:00
Julio López
ae9f1c734b fix(server): ensure repo disconnection on server start exit (#3980)
Ensure repository disconnection at the end of the `server start` CLI command.
This was caught as a result of fixing the test below.

Fix `TestServerStartInsecure`:
Remove `--password=xxx` parameter, which causes a server start failure
due to incorrect repo password, and not for the case being checked,
which is the lack of the `--insecure` parameter.

Update test comments accordingly.
2024-07-11 18:51:12 -07:00
chaitalisg
3801e59475 test(general): run maintenance action in robustness (#3927)
Adds the maintenance action to multi-client robustness jobs.
The robustness jobs do not run a maintenance action until now.
---------
Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2024-07-03 20:34:50 -07:00
chaitalisg
e7aa37cce3 test(general): ignore dir not found error during delete action in robustness tests (#3944)
The robustness tests perform delete actions on random subdirectories and
files. If the actions encounter `directory not found` error, the framework 
returns a `no-op` error. 

This change ignores the `no-op` errors specifically for "delete" actions.
This change will reduce the failure frequency when a delete actions on the
source directory result in a no-op.
2024-06-28 16:33:16 -07:00
Julio López
1f9f9a1846 chore(general): use non-formatting log variants when there is no formatting (#3931)
Use non-formatting logging functions for message without formatting.
For example, `log.Info("message")` instead of `log.Infof("message")`

Configure linter for printf-like functions
2024-06-18 23:13:17 -07:00
chaitalisg
7514a3563f test(general): reduce the file write weight (#3929)
The robustness test `TestRandomizedSmall` generate file action gets
picked up four to eight times more frequently than the other actions.
This PR reduces the frequency of the file generation action so that the
test is more representative of the user workflow.
2024-06-18 13:59:48 -07:00
chaitalisg
4f09136c0c test(general): add delete actions to robustness suite (#3879)
The robustness framework runs do not cover delete actions at the moment. 

This change adds the following actions to the robustness jobs
- delete random subdirectories
- delete contents of directories
2024-06-17 12:20:25 -07:00
Jarek Kowalski
fcb8197f3f chore(ci): upgraded linter to 1.59.0 (#3883) 2024-05-29 20:31:57 -07:00
Eugene Sumin
2b92388286 refactor(general): Increase restore progress granularity (#3655)
When restoring huge file(s), the progress reporting is done in a bit
weird way:

```
kopia_test % kopia snapshot restore ka2084d263182164b6cf3456668e6b6da /Users/eugen.sumin/kopia_test/2
Restoring to local filesystem (/Users/eugen.sumin/kopia_test/2) with parallelism=8...
Processed 6 (5.4 GB) of 5 (5.4 GB) 1.6 MB/s (100.0%) remaining 0s.
Processed 6 (5.4 GB) of 5 (5.4 GB) 1.6 MB/s (100.0%) remaining 0s.
Processed 6 (5.4 GB) of 5 (5.4 GB) 1.6 MB/s (100.0%) remaining 0s.
Processed 6 (5.4 GB) of 5 (5.4 GB) 1.5 MB/s (100.0%) remaining 0s.
Processed 6 (5.4 GB) of 5 (5.4 GB) 1.5 MB/s (100.0%) remaining 0s.
Processed 6 (5.4 GB) of 5 (5.4 GB) 1.5 MB/s (100.0%) remaining 0s.
Restored 5 files, 1 directories and 0 symbolic links (5.4 GB).
```
In fact, the amount of restored data is dumped when particular file
completely restored.

This PR contains the least invasive change, which allows us to see
progress update while file is downloaded from object storage.
```
Restoring to local filesystem (/Users/eugen.sumin/kopia_test/55) with parallelism=8...
Processed 2 (3.1 MB) of 5 (1.8 GB).
Processed 4 (459.6 MB) of 5 (1.8 GB) 270.3 MB/s (25.2%) remaining 4s.
Processed 4 (468.7 MB) of 5 (1.8 GB) 269 MB/s (25.7%) remaining 4s.
Processed 4 (741.6 MB) of 5 (1.8 GB) 269 MB/s (40.6%) remaining 3s.
Processed 4 (1.1 GB) of 5 (1.8 GB) 280 MB/s (57.6%) remaining 2s.
Processed 5 (1.4 GB) of 5 (1.8 GB) 291.1 MB/s (75.2%) remaining 1s.
Processed 5 (1.4 GB) of 5 (1.8 GB) 289.8 MB/s (75.6%) remaining 1s.
Processed 5 (1.6 GB) of 5 (1.8 GB) 270.2 MB/s (85.3%) remaining 0s.
Processed 5 (1.7 GB) of 5 (1.8 GB) 256.3 MB/s (95.0%) remaining 0s.
Processed 6 (1.8 GB) of 5 (1.8 GB) 251 MB/s (100.0%) remaining 0s.
Processed 6 (1.8 GB) of 5 (1.8 GB) 251 MB/s (100.0%) remaining 0s.
Restored 5 files, 1 directories and 0 symbolic links (1.8 GB).
```

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2024-05-10 09:47:13 -07:00
Julio López
ca1962f6e4 refactor(general): user password hashing and key derivation helpers (#3821)
Code movement and simplification, no functional changes.

Objectives:
- Allow callers specifying the needed key (or hash) size, instead of
hard-coding it in the registered PBK derivers. Conceptually, the caller
needs to specify the key size, since that is a requirement of the
(encryption) algorithm being used in the caller. Now, the code changes
here do not result in any functional changes since the key size is
always 32 bytes.
- Remove a global definition for the default PB key deriver to use.
Instead, each of the 3 use case sets the default value.

Changes:
- `crypto.DeriveKeyFromPassword` now takes a key size.
- Adds new constants for the key sizes at the callers.
- Removes the global `crypto.MasterKeySize` const.
- Removes the global `crypto.DefaultKeyDerivationAlgorithm` const.
- Adds const for the default derivation algorithms for each use case.
- Adds a const for the salt length in the `internal/user` package, to ensure
  the same salt length is used in both hash versions.
- Unexports various functions, variables and constants in the `internal/crypto`
  & `internal/user` packages.
- Renames various constants for consistency.
- Removes unused functions and symbols.
- Renames files to be consistent and better reflect the structure of the code.
- Adds a couple of tests to ensure the const values are in sync and supported.
- Fixes a couple of typos

Followups to:
- #3725
- #3770
- #3779
- #3799
- #3816

The individual commits show the code transformations to simplify the
review of the changes.
2024-04-26 23:30:56 -07:00
Sirish Bathina
1e98511c2e feat(general): key derivation algorithm for cache encryption (#3799)
Add an option to select the password-based key derivation algorithm
for the local cache encryption key when connecting to a kopia
repository server.
2024-04-25 17:45:12 -07:00
Sirish Bathina
c71f57d83c feat(general): allow setting key derivation algorithm for format blob (#3779)
Adds support to set the algorithm to derive the key used to encrypt
the repository format blob.
2024-04-24 14:07:19 -07:00
Jarek Kowalski
211e28c98c chore(repository): BREAKING CHANGE remove support for HTTP-based repository API (#3745)
Remove support for HTTP-based repository API
2024-04-17 16:23:58 -07:00
coderwander
f125f09ddc chore: fix some typos in comments (#3805)
Signed-off-by: coderwander <770732124@qq.com>
2024-04-16 14:48:03 -07:00
Jarek Kowalski
b55d5b474c refactor(repository): refactored internal index read API to reduce memory allocations (#3754)
* refactor(repository): refactored internal index read API to reduce memory allocations

* fixed stress test flake, improved debuggability

* fixed spurious checklocks failures

* post-merge fixes

* pr feedback
2024-04-12 22:59:11 -07:00
Jarek Kowalski
09415e0c7d chore(ci): upgraded to go 1.22 (#3746)
Upgrades go to 1.22 and switches to new-style for loops

---------

Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2024-04-08 09:52:47 -07:00
lvyaoting
67f87a5450 chore(general): fix function names in comment (#3786)
Signed-off-by: lvyaoting <lvyaoting@outlook.com>
2024-04-07 21:33:33 -07:00
NickIAm
3da0473219 fix(cli): restore objects with I prefix fails (#3062)
* Fix restoring objects with I prefix
set default of snapshot-time to 'latest' as noted in the help output

* Change test of restore to check it works without a time given
This is because --snapshot-time defaults to "latest" now.
2024-03-26 21:03:46 -07:00
Nick
8c081add53 chore(server): Disable legacy API by default (#3730) 2024-03-13 11:11:09 -07:00
Jarek Kowalski
fb8d9c3bf8 chore(deps): removed direct deprecated protobuf dependency (#3720) 2024-03-11 21:47:14 -07:00
Jarek Kowalski
29cd545c33 chore(ci): upgrade linter to 1.56.2 (#3714) 2024-03-09 10:39:11 -08:00
chaitalisg
c07fb8b14f test(general): Increase timeout to check for generated TLS cert (#3696)
* add debug messages

* increase wait time for tls cert

* add error messages for easier debugging

* Update tests/tools/kopiarunner/kopia_snapshotter.go

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

* add comment

---------

Co-authored-by: Nick <nick@kasten.io>
2024-03-05 22:54:39 +00:00
Aaron Alpar
769d5f3a50 fix(ci): fix shadow-copy test (#3629)
Followup for #3624
Fixes #3628

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2024-02-06 20:51:55 -08:00
Maxim Khitrov
f62ef51700 feat(snapshots): Implement volume shadow copy support on Windows (#3543)
* Implement volume shadow copy support on Windows

* Update go-vss version

* Fix unused variables

* Rename upload_actions*.go files

* Move vss settings to a separate policy section

* Handle existing shadow copy root

* Fix tests

* Fix lint issues

* Add cli policy test

* Add OS snapshot integration test

* Add GitHub Actions VSS test

* Fix "Incorrect function" error for root VSS snapshots

* Rename err to finalErr in createOSSnapshot

* Add OSSnapshotMode test

* Do not modify paths starting with \\?\ on Windows

* Allow warning messages in logfile tests

* Fix ignorefs not wrapping OS snapshot directory

* Retry VSS creation if another op was in progress

---------

Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2024-02-03 21:44:41 -08:00
Jarek Kowalski
3fed193051 fix(ci): fixed HTMLUI E2E test by switching to macOS runner (#3613)
* fix(test): fixed HTMLUI E2E test

* switched runner to macOS
2024-02-03 15:41:25 -08:00
Jarek Kowalski
a8e4d50600 build(deps): upgraded linter to v1.55.2, fixed warnings (#3611)
* build(deps): upgraded linter to v1.55.2, fixed warnings

* removed unsafe hacks with better equivalents

* test fixes
2024-02-02 23:34:34 -08:00
Julio Lopez
c56d330383 feat(cli): handle SIGTERM (#3562)
* refactor(test): allow signaling sub-process from testenv.CLIExeRunner
* test(cli): add test for handling SIGTERM
* feat(general): catch and process SIGTERM for termination
* refactor(cli): rename function cli.App.onTerminate
  Renames function from onCtrlC to a more generic onTerminate
2024-01-11 18:02:31 -08:00
Julio Lopez
ef803b2185 nit: simplify block (#3528)
Fix typo as well

Followup to #3462
2023-12-19 14:01:54 -08:00
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