Commit Graph

637 Commits

Author SHA1 Message Date
Matthieu MOREL
5c85ca6bb0 refactor(deps): migrate from go.uber.org/multierr to standard errors (#3761)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-04-01 23:16:20 -07:00
Aaron Alpar
a4260e0185 fix(providers): Reduce memory allocation (gc thrash) (#3695)
Avoid minio allocations by implementing `ReadAt` function.
This change causes Minio libraries to reduce memory allocations.
Specifically, buffer allocations for S3 upload.
Add tests for new functionality.

---------

Co-authored-by: Shikhar Mall <shikhar.mall@veeam.com>
Co-authored-by: Nick <nick@kasten.io>
2024-04-01 15:10:27 -07:00
Julio López
e600c15b6b fix(general): disable writes on index loads (#3646)
Change default 'allowWritesOnIndexLoad' to false when env var is unset
Add TestNoEpochAdvanceOnIndexRead

Ref:
- Followup to #3645
- Avoid index (epoch) cleanup and compaction during index reads #3638
- Make "read" commands/operations really read-only.  #3639
2024-03-31 22:27:49 -07:00
Julio López
522209369c refactor(test): explicitly advance epoch in TestMaybeCompactSingleEpoch_CompactionError (#3755)
Ref:
- #3638
2024-03-27 12:49:53 -07:00
Jarek Kowalski
7278f570e2 chore(ci): upgraded linter to 1.57.1 (#3753) 2024-03-25 22:20:38 -07:00
Julio López
fdb6d3c097 refactor(general): add epoch.Manager.MaybeGenerateRangeCheckpoint (#3727)
* epoch manager: factor out getRangeToCompact
* epoch manager: add epoch.Manager.MaybeGenerateRangeCheckpoint
* test epoch.Manager.MaybeGenerateRangeCheckpoint
2024-03-22 15:29:11 -07:00
Julio López
f8352275ba refactor(general): add epoch.Manager.CleanupMarkers (#3726)
Includes tests for CleanupMarkers
2024-03-19 18:35:29 -07:00
Julio López
6236ff7fba refactor(general): add epoch.Manager.MaybeCompactSingleEpoch (#3728)
Add:
- epoch.Manager.MaybeCompactSingleEpoch
- getCompactedEpochRange helper
- oldestUncompactedEpoch helper
- TestOldestUncompactedEpoch
- Tests for MaybeCompactSingleEpoch

Ref:
- Subset and dependency of #3651
- Depends on #3735
- Avoid index (epoch) cleanup and compaction during index reads #3638
- Make "read" commands/operations really read-only.  #3639
2024-03-19 17:46:45 -07:00
Julio López
316356a031 refactor(general): closedIntRange (#3735)
Refactoring for the original implementation with intRange and
getKeyRange from closed-open ranges [lo, hi) to closed ranges: [lo, hi].
The primary motivation is for consistency with the implementation
of epoch.RangeMetadata in the same package, and thus avoid
confusion and reduce cognitive load.

Changes:

- adds a getContiguousKeyRange wrapper that checks for contiguity.
- getKeyRange simply returns a range with minimum and maximum
  values for the keys in the map.
- changes the range implementation from closed-open ranges [lo, hi)
   to closed ranges: [lo, hi] where both lo and hi are included in the range.
- Additional unit tests are included.
- renames intRange to closedIntRange to reflect new functionality.

Ref:
- Follow up refactor(general): add epoch.getKeyRange helper #3721
- Needed for refactor(general): add epoch.Manager.MaybeCompactSingleEpoch #3728
- Avoid index (epoch) cleanup and compaction during index reads #3638
2024-03-18 22:58:16 -07:00
Sirish Bathina
4ea6cf98d1 update min salt size to 16 (#3732) 2024-03-13 15:02:33 -07:00
Nick
8647f71299 fix(cli): Output error msg returned by API server payload when possible (#3724)
Updates unit test expected error output
2024-03-13 18:29:50 +00:00
Sirish Bathina
ddcdfdb55a changes for switching key derivation (#3725) 2024-03-13 00:34:46 +00:00
Julio López
4a06623eb6 refactor(general): add clarification comment (#3723)
Followup to #3721

Co-authored-by: Nick <nick@kasten.io>
2024-03-12 11:52:25 -07:00
Julio López
e143c71e6d refactor(general): add epoch.getKeyRange helper (#3721)
Extracted from #3651.

Thanks to @plar and @redgoat650 for the suggestions.

Ref:

- #3603
- #3645
- #3638
- #3639
2024-03-12 11:05:50 -07:00
Julio López
e347710611 nit: fix comment (#3722) 2024-03-11 22:23:56 -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
Nick
f5efb670b9 fix(server): Return internal server errors for Content Get errors (#3713) 2024-03-08 07:38:16 -08:00
Julio López
be49fcd42b refactor(general): add epoch.Manager.MaybeAdvanceEpoch helper (#3709)
Add
- TestMabyeAdvanceEpoch
- TestMabyeAdvanceEpoch_Empty
- TestMaybeAdvanceEpoch_Error
- TestMaybeAdvanceEpoch_GetParametersError

Ref:
- #3638
- #3645
- #3651
2024-03-06 17:12:49 -08:00
Jarek Kowalski
3e21bb5973 feat(repository): added metrics timeseries computation (#3678)
* feat(repository): added metrics timeseries computation

This code is not used anywhere yet, will be used for reporting over
repository metrics.

* fixed checklocks

* Update internal/metrics/metrics_timeseries.go

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

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2024-03-02 22:34:08 -08:00
Aaron Alpar
d034a37682 feat(cli): 1B: PPROF extensions: load profile config (#3668)
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2024-02-27 12:30:14 -08:00
Julio López
8d9e8d580e test(general): fix TestIndexEpochManager_CompactionAlwaysFails (#3677) 2024-02-23 20:42:39 -08:00
Aaron Alpar
58ea857f14 rename env var (#3669) 2024-02-21 13:24:54 -08:00
Jarek Kowalski
d0fc1e03c4 fix(server): do not make blocking calls inside server status API (#3666)
also reduce global server lock scope
2024-02-21 12:34:16 -08:00
Aaron Alpar
a726f11a04 feat(cli): 1a: PPROF extensions: PEM dump (#3665)
* c1a commit

* fixup package comment

* happy lint
2024-02-21 00:07:37 +00:00
Jarek Kowalski
524ffaf4b8 refactor(repository): added context to potentially blocking repository methods (#3654)
Primarily for wiring a context.Context to a call to content.Manager.refresh,
which was using a detached context.
2024-02-20 14:48:23 -08:00
Julio López
06ff37fa63 refactor(general): allow disabling writes on index index loads (#3645)
Conditionally disables epoch index maintenance operations when loading indexes.
This prevents (potentially expensive) cleanup write operations on the index
read path.
The behavior is controlled via the `epoch.Manager.allowCleanupWritesOnIndexLoad`
field, which can be temporarily overridden via an environment variable.
This override mechanism will be removed in the near future.

Refs:

- #3174
- #3224
- #3225
- #3638
- #3639
2024-02-16 14:59:06 -08:00
Julio López
1892a9f1d9 refactor(general): move index cleanup out to refreshAttempt (#3603)
Refactor: move index compaction and cleanup out of refreshAttemptLocked

Introduces an `allowWritesOnLoadHelper` to check whether or not writes
can be performed when loading the indexes. Currently this is only
a function of whether the storage is in read-only mode. In the near
future, an explicit flag will be added to control this behavior.

Fix epoch manager: avoid single-epoch compaction when writes are disallowed.
Functional change: prevents compacting single epochs when writes are
disallowed, that is when using read-only storage. Currently, the epoch
manager will attempt to perform single-epoch compactions for all
eligible epochs, even on read-only storage.

Ref:
- #3224
- #3225
- #3638
- #3639
2024-02-16 10:25:58 -08:00
Julio López
ed9d0c281e refactor(cli): miscellaneous code simplifications (#3607)
* refactor(cli): code simplification in onTerminate callback function
* refactor(test): quote strings, via %q, in assertion failure message

---------

Authored-by: Aaron Alpar <aaron.alpar@veeam.com>
2024-02-06 21:37:51 -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
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
Jarek Kowalski
c478141bbf refactor(repository): refactor internal/repolog package to support writing metrics in the future (#3610)
* renamed internal/repolog to internal/repodiag

* refactored initialization

* additional tests

* linter fixes
2024-02-02 22:19:24 -08:00
Nick
1d6f852cd6 fix(cli): Ensure scrubber checks all fields recursively for sensitive tags (#3589)
* Fix ScrubSensitiveData to scrub recursively
* Extend test with additional cases
2024-01-26 01:46:01 +00:00
Christoph Anderson
ddcf7b51cc feat(ui): Add the ability to change font-sizes (#3515)
Extending UIPreferences to support font sizes

---
Authored-by: lupusA <lupuapps@gmail.com>
2024-01-10 19:43:41 -08:00
Julio Lopez
871e2e0082 test(general): use require.Eventually to ensure test stops (#3530) 2023-12-19 15:09:56 -08:00
Julio Lopez
a447f34e24 test(general): fix race in TestIndexEpochManager_NoCompactionInReadOnly (#3517) 2023-12-17 23:37:14 -08:00
Julio Lopez
ab8680c997 refactor(general): minor cleanups related to index managers (#3518)
Rename faketime.AutoAdvance parameter to start for clarity

Clarify faketime.ClockTimeWithOffset.Advance documentation

Refactor `faketime.TimeAdvance`:
  Add `faketime.NewAutoAdvance` to create auto-advancing
  `TimeAdvance` clocks.

Refactor faketime.NewTimeAdvance to return non-auto-advancing clocks,
which can still be explicitly advanced.
Removes the now unused `autoDelta` parameter, since it is always 0.

Rename function to `sm.setupCachesAndIndexManagers`
It matches the current implementation better.

Unexport `indexblob.ManagerV1.epochMgr`

Rename function for clarity to `advanceEpochMarker`

Cleanup logs after cleaning up epoch manager.
This is consistent with quick maintenance as well.

Make 'def' a test-local variable instead of a package-level
variable, it is not used outside this test.

Cleanup epoch test newTestEnv()

Misc:
* Reword comment and fix typo
* Fix log message
* `log.Debug` for non-formatted output
2023-12-17 22:21:28 -08:00
Julio Lopez
92e4f165d7 refactor(general): minor cleanups (#3495)
Unexport epoch.Manager.forceAdvanceEpoch. It is only used in tests.
Moved implementation to the `epoch_manager_test.go` file.

Remove `RetentionMode` and `RetentionPeriod` from `content.ManagerOptions` struct
2023-12-08 00:13:17 -08: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
Jarek Kowalski
c8d1b221e2 refactor(repository): added fs.DirectoryIterator (#3365)
* refactor(repository): added fs.DirectoryIterator

This significantly reduces number of small allocations while
taking snapshots of lots of files, which leads to faster snapshots.

```
$ runbench --kopia-exe ~/go/bin/kopia \
   --compare-to-exe ~/go/bin/kopia-baseline --min-duration 30s \
   ./snapshot-linux-parallel-4.sh
DIFF duration: current:5.1 baseline:5.8 change:-13.0 %
DIFF repo_size: current:1081614127.6 baseline:1081615302.8 change:-0.0 %
DIFF num_files: current:60.0 baseline:60.0 change:0%
DIFF avg_heap_objects: current:4802666.0 baseline:4905741.8 change:-2.1 %
DIFF avg_heap_bytes: current:737397275.2 baseline:715263289.6 change:+3.1 %
DIFF avg_ram: current:215.0 baseline:211.5 change:+1.6 %
DIFF max_ram: current:294.8 baseline:311.4 change:-5.3 %
DIFF avg_cpu: current:167.3 baseline:145.3 change:+15.1 %
DIFF max_cpu: current:227.2 baseline:251.0 change:-9.5 %
```

* changed `Next()` API

* mechanical move of the iterator to its own file

* clarified comment

* pr feedback

* mechanical move of all localfs dependencies on os.FileInfo to a separate file

* Update fs/entry.go

Co-authored-by: ashmrtn <3891298+ashmrtn@users.noreply.github.com>

* Update fs/entry_dir_iterator.go

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

* doc: clarified valid results from Next()

---------

Co-authored-by: ashmrtn <3891298+ashmrtn@users.noreply.github.com>
Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2023-10-05 02:45:44 +00:00
PhracturedBlue
e653ec0a02 refactor(repository): Move encryption into a common package in preparation to handle secrets (#3351) 2023-09-24 17:44:50 -07:00
PhracturedBlue
bcb07da5f3 fix(cli): Convert --run-missed from bool to Enum (#3337) 2023-09-22 10:18:19 -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
164dcceb11 feat(server): introduced generic scheduler (#3293)
This is a generic scheduler that executes a loop consisting of:

- determining upcoming set of events
- waiting until the appropriate time
- triggering the events
2023-09-12 07:37:41 -07:00
PhracturedBlue
30d6ef2ceb feat(ui): Allow specifying whether local or all snapshots are shown by default in the UI (#3289) 2023-09-11 22:49:36 -07:00
Jarek Kowalski
aa064bb442 fix(providers): fixed list/get caching with rclone providers (#3284)
Added improved providervalidation logic which tests for read-after-write
property between connections. The new test was failing before the change
and is now passing for Google Drive, OneDrive and DropBox.
2023-09-09 13:07:53 -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
Jarek Kowalski
80423cf5f6 feat(server): fixed server logging file & console (#3262)
Previously some logs from a running server were only kept in memory
(including storage activity logs) which was confusing to many folks.

This changes the behavior so that logs are sent to their regular
(console/file) file locations in addition to the UI tasks.

Old behavior can be restored by adding `--no-persistent-logs` to
server.
2023-09-02 18:10:18 -07:00
Jarek Kowalski
20928258d6 test(general): fixed TestOnNthCompletion test flake, which was 1-5/10000 runs (#3263) 2023-09-02 16:04:36 -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