Commit Graph

572 Commits

Author SHA1 Message Date
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
Denis Voytyuk
0d7a4de5b7 test(general): added tests for parallelwork (#2942) 2023-04-21 00:11:51 -07:00
Jarek Kowalski
cbc204a2c7 fix(repository): remove metrics.Registry from repo.Repository (#2944) 2023-04-14 19:16:10 -07:00
Denis Voytyuk
5d8e1134c1 test(general): added unit tests for diff (#2931) 2023-04-14 19:05:54 -07:00
Denis Voytyuk
2063a343f3 test(general): added tests for iocopy (#2932) 2023-04-14 16:57:57 -07:00
Denis Voytyuk
36e2b9ff89 test(general): added tests for tlsutil (#2933) 2023-04-14 16:56:46 -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
Denis Voytyuk
bfeef01d23 test(general): added unit tests for freepool (#2930) 2023-04-13 18:58:16 -07:00
Aaron Alpar
ac8446b028 fix(deps-dev): fixup mutex for make check-locks (#2920) 2023-04-11 15:58:20 -04:00
Shikhar Mall
9f9309ad2a feat(repository): live cache eviction of expired BLOBs in persistent LRU content cache (#2879)
* feat(repository): live cache eviction for persistent lru content cache

* Update internal/cache/persistent_lru_cache.go

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

* merge the mutex cache into list cache

---------

Co-authored-by: Shikhar Mall <small@kopia.io>
Co-authored-by: Ali Dowair <adowair@umich.edu>
2023-04-08 04:30:45 +00:00
Christoph Anderson
c624b8eece fix(general): Fixed ordering in function "isAbs" in ospath (#2850)
The special case (Windows) has to be checked before "filepath.IsAbs".
The test for internal\ospath now return success.

Co-authored-by: lupusA <lupuapps@gmail.com>
2023-03-31 04:19:14 +00:00
Aaron Alpar
cc7a413d0d fix(general): fix-up *Fault with lock (#2855)
Add concurrency safety for helper functions.

---

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
Co-authored-by: Ali Dowair <adowair@umich.edu>
Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2023-03-28 03:03:56 +00: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
Jarek Kowalski
92291a61e1 feat(repository): added RepositoryWriter.ReplaceManifests (#2747)
This simplifies use cases where we intend to replace a manifest uniquely
identified by a set of labels with another one as is the case for
policies.

This helped fix annoying test flake on Windows where the clock is not
guaranteed to move forward when read in quick succession.

This is now passing on Windows:

```
$ go test -timeout 1000s ./internal/server -run TestSourceRefreshesAfterPolicy -count=1000
```
2023-03-12 00:44:28 +00: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
Jarek Kowalski
939152cfda chore(ci): upgraded linter to 1.51.1, minor style fixes (#2748) 2023-02-09 06:47:36 +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
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
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
c2cc25c504 feat(repository): added internal/metricid package (#2626)
This manages mapping of metric names to IDs which allows efficient JSON
representation of counter values for each set of metrics where
only values are in the index order.

This will be used in the telemetry protocol and for storing counters in
the repository.

Added test that ensures all metrics registered in a repository have
the corresponding mapping.
2022-12-05 04:41:42 +00:00
Jarek Kowalski
7cc93265ef refactor(repository): moved cache protection to separate package (#2621) 2022-12-03 18:47:01 +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
82b3f1c648 refactor(repository): refactored server repository implementations (#2595)
This extracts common bits shared by HTTP and GRPC implementations into
one.
2022-11-22 04:29:05 +00:00
Jarek Kowalski
f50779241e refactor(repository): added metrics aggregation, removed gauges (#2594) 2022-11-22 04:18:21 +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
3d38ec8405 feat(repository): added Snapshot(bool) option to reset metrics (#2588) 2022-11-19 05:29:24 +00:00
Jarek Kowalski
78edd92692 refactor(repository): refactored Prometheus metrics (#2532)
This may be a breaking change for users who rely on particular kopia metrics (unlikely):

- introduced blob-level metrics:

* `kopia_blob_download_full_blob_bytes_total`
* `kopia_blob_download_partial_blob_bytes_total`
* `kopia_blob_upload_bytes_total`
* `kopia_blob_storage_latency_ms` - per-method latency distribution
* `kopia_blob_errors_total` - per-method error counter

- updated cache metrics to indicate particular cache

* `kopia_cache_hit_bytes_total{cache="CACHE_TYPE"}`
* `kopia_cache_hit_total{cache="CACHE_TYPE"}`
* `kopia_cache_malformed_total{cache="CACHE_TYPE"}`
* `kopia_cache_miss_total{cache="CACHE_TYPE"}`
* `kopia_cache_miss_errors_total{cache="CACHE_TYPE"}`
* `kopia_cache_miss_bytes_total{cache="CACHE_TYPE"}`
* `kopia_cache_store_errors_total{cache="CACHE_TYPE"}`

where `CACHE_TYPE` is one of `contents`, `metadata` or `index-blobs`

- reorganized and unified content-level metrics:

* `kopia_content_write_bytes_total`
* `kopia_content_write_duration_nanos_total`

* `kopia_content_compression_attempted_bytes_total`
* `kopia_content_compression_attempted_duration_nanos_total`
* `kopia_content_compression_savings_bytes_total`
* `kopia_content_compressible_bytes_total`
* `kopia_content_non_compressible_bytes_total`
* `kopia_content_after_compression_bytes_total`

* `kopia_content_decompressed_bytes_total`
* `kopia_content_decompressed_duration_nanos_total`

* `kopia_content_encrypted_bytes_total`
* `kopia_content_encrypted_duration_nanos_total`

* `kopia_content_hashed_bytes_total`
* `kopia_content_hashed_duration_nanos_total`

* `kopia_content_deduplicated_bytes_total`

* `kopia_content_read_bytes_total`
* `kopia_content_read_duration_nanos_total`

* `kopia_content_decrypted_bytes_total`
* `kopia_content_decrypted_duration_nanos_total`

* `kopia_content_uploaded_bytes_total`

Also introduced `internal/metrics` framework which constructs Prometheus metrics in a uniform way and will allow us to include some of these metrics in telemetry report in future PRs.
2022-11-10 05:30:06 +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
c06d50d218 fix(ci): increased timeout in flaky TestSourceRefreshesAfterPolicy on Windows (#2476) 2022-10-02 03:36:23 +00:00
Jarek Kowalski
dcf6d1c2e1 feat(general): always try O_TMPFILE on Linux when creating temporary files (#2407) 2022-09-14 09:48:02 -07:00
Jarek Kowalski
33fa5cbd50 feat(general): added tempfile package (#2402)
* feat(general): added tempfile package

* use tempfile.Create() in bigmap
2022-09-14 05:37:47 +00:00
Jarek Kowalski
b9e9ef3b38 feat(repository): improve performance when snapshotting to a repository server (#2394)
Benchmarked from macOS client to a Linux server over Wifi connection:
(2-5ms latency)

linux 5.14.8 (1.1 GB) to a clean repository:

Before: 240s After: 27s (90% faster)

Fixes #2372
2022-09-11 07:43:34 -07:00
Jarek Kowalski
b38ace2513 feat(server): added tracing spans for gRPC server (#2393) 2022-09-11 07:13:59 +00:00
Jarek Kowalski
645e680a8f feat(general): reduce memory usage in maintenance, snapshot fix and verify (#2365) 2022-09-10 09:36:17 -07:00
Jarek Kowalski
28ce29eab4 feat(repository): added Set and Map backed by custom on-disk hashtable (#2364)
* feat(repository): added bigmap Set and Map backed by custom on-disk hashtable

* additional test coverage for corner cases

* profile flags

* exclude bigmapbench from code coverage

* refactored based on conversation with Julio

The concern was that values stored on disk are not encrypted.

* bigmap.Map - implements encryption of values
* bigmap.Set - stores keys only, so no encryption necessary
* bigmap.internalMap - used as backing structure for Map and Set

* implemented benchmark with values
2022-09-10 15:47:53 +00:00
Jarek Kowalski
7bda16ab33 feat(repository): introduced fs.UTCTimestamp (#2343)
Fixes #2342
2022-09-02 10:35:59 -07:00
ashmrtn
5c88bcf1a6 feat(snapshots): Callback for when uploader finishes processing a file (#2331)
* Make callback for upload file completion

Callback does not indicate that a file will be reachable immediately in
the resulting snapshot, but does indicate that the uploader is done
processing the file in some way (either via uploading data or finding a
previous version in the repo) and whether there was an error processing
the file.

* Tests for new FinishedFile callback

Ensure hadErr is properly populated and FinishedFile is called even if
the file was considered cached.

* Refine comment on interface function slightly

* Give callback error instead of bool about error

* Add locks around concurrent accesses in test
2022-08-22 20:42:27 +01:00
Ricardo Pescuma Domenecci
04f54000a6 feat(server): Added ECC to server api (#2314)
* feat(server): Added ECC to server api

* feat(server): Add format version to repo status api

* Change requested in PR

* Updated htmlui
2022-08-19 08:24:04 -07:00
Jarek Kowalski
4d55f91070 chore(ci): disable long file names in GetInterestingTempDirectoryName() when ENABLE_LONG_FILENAMES=false (#2295) 2022-08-09 06:55:30 +00: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
419c7acb11 fix(repository): fixed V1 key derivation bug from previous refactoring (#2286)
See 23299c3451
2022-08-08 21:45:08 -07:00
Jarek Kowalski
23299c3451 refactor(repository): ensure MutableParameters are never cached (#2284) 2022-08-06 18:11:32 -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
b9be9632a2 feat(repository): added required features to the repository (#2220)
* feat(repository): added `required features` to the repository

This is intended for future compatibility to be able to reliably
stop old kopia client from being able to open a repository when
the old code does not understand new `required feature`.

Required features are checked on startup and periodically using the
same method as upgrade lock, where they will return errors during blob
operations.

* pr feedback
2022-07-29 09:31:17 -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