Commit Graph

67 Commits

Author SHA1 Message Date
Julio Lopez
31a1fd25ba style(general): cleanup linter config (#4538)
- use 'localmodule' for gci linter config
- enabled 'wastedassign' linter
- remove unused assignment
- prevent re-introducing dependencies
- remove unused //nolint directive
- disable zerologlint linter
2025-04-30 10:37:03 -07:00
Matthieu MOREL
8a176255c0 fix(general): enable wsl for all go files (#4524)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 13:01:20 -07:00
Matthieu MOREL
675e958877 chore(ci): bump golangci-lint to v2.1.2 (#4500)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-15 22:49:13 -07:00
Jarek Kowalski
eb1cf64c27 chore(ci): upgraded linter to 1.62.0 (#4250) 2024-11-16 07:16:50 -08:00
Julio López
961a39039b refactor(general): use errors.New where appropriate (#4160)
Replaces 'errors.Errorf\("([^"]+)"\)' => 'errors.New("\1")'
2024-10-05 19:05:00 -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
Julio López
4786ab3cbb refactor(general): remove no-longer used functions and tests (#3924)
Followup cleanup for #3919

All the changes are in the `epoch` package

Summary:
- Removal of now unused code and tests.
- Refactoring to simplify test and remove a linter annotation.
- Fix a typo
2024-06-18 12:24:56 -07:00
Julio López
2a79224a33 fix(general): relax epoch compaction check for contiguous ranges (#3919)
While the current implementation should not produce non-contiguous
ranges, this invariant check may be too stringent, in particular for
repositories created and mutated by older kopia (client) processes.

For backwards compatibility the check is relaxed to allow operations to
proceed in older repositories.
2024-06-17 16:25:47 -07:00
Julio López
d9b2aab8b9 fix(general): add parameter to log message (#3904) 2024-06-06 13:44:48 -07:00
Jarek Kowalski
fcb8197f3f chore(ci): upgraded linter to 1.59.0 (#3883) 2024-05-29 20:31:57 -07:00
Julio López
ad06bb20b1 refactor(general): remove ability to enable compaction on index load (#3834)
Cleanup.

- Fixes: #3638
- #3639
2024-05-01 14:33:46 -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
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
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
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
29cd545c33 chore(ci): upgrade linter to 1.56.2 (#3714) 2024-03-09 10:39:11 -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
Julio López
8d9e8d580e test(general): fix TestIndexEpochManager_CompactionAlwaysFails (#3677) 2024-02-23 20:42:39 -08: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 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
ashmrtn
b57d16d4a7 fix(repository): skip epoch compaction and advancement on read-only storage (#3225)
* Set epoch manager not to compact if readonly

Thread read-only parameter through the stack and make use of it when
loading epochs.

* Add test for manager read-only mode

Uses a bit of a contrived setup, but the state used in the test is
possible to reach given the right set of conditions and can cause the
manager to get stuck trying to refresh.

* Pull read-only status from Storage provider
2023-08-21 15:29:13 -07: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
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
Edward Betts
1e97574391 fix(general): correct spelling mistakes (#2684) 2023-01-21 07:37:15 -08: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
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
23299c3451 refactor(repository): ensure MutableParameters are never cached (#2284) 2022-08-06 18:11:32 -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
Jarek Kowalski
e591f4b79b chore(ci): skip non-deterministic tests when computing code coverage (#1817) 2022-03-09 07:42:01 -08:00
Jarek Kowalski
369d304084 refactor(repository): better context cancelation handling (#1802)
Instead of ignoring context cancelation in Open(), ensure we don't
spawn goroutines that might be canceled.
2022-03-06 16:56:30 -08:00
Julio Lopez
d68cc9f647 refactor(general): misc nits (#1729)
* nit: clarify maxCleanupTime documentation

* refactor: runTaskIndexCompactionQuick helper

Expand one-line wrapper

* nit: improve error message

* nit: clarify error message

* nit: use errors.New for static error messages
2022-02-04 17:38:40 -08:00
Jarek Kowalski
32ed220a6c build(lint): enabled gochecknoglobals and tagged existing globals (#1664) 2022-01-15 12:54:56 -08:00
Jarek Kowalski
d9afb15e4d maintenance: moved costly epoch manager cleanup to maintenance (#1616) 2021-12-22 21:34:26 -08:00
Jarek Kowalski
7401684e71 blob: replaced blob.Storage.SetTime() method with blob.PutOptions.SetTime (#1595)
* sharded: plumbed through blob.PutOptions

* blob: removed blob.Storage.SetTime() method

This was only used for `kopia repo sync-to` and got replaced with
an equivalent blob.PutOptions.SetTime, which wehn set to non-zero time
will attempt to set the modification time on a file.

Since some providers don't support changing modification time, we
are able to emulate it using per-blob metadata (on B2, Azure and GCS),
sadly S3 is still unsupported, because it does not support returning
metadata in list results.

Also added PutOptions.GetTime, which when set to not nil, will
populate the provided variable with actual time that got assigned
to the blob.

Added tests that verify that each provider supports GetTime
and SetTime according to this spec.

* blob: additional test coverage for filesystem storage

* blob: added PutBlobAndGetMetadata() helper and used where appropriate

* fixed test failures

* pr feedback

* Update repo/blob/azure/azure_storage.go

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

* Update repo/blob/filesystem/filesystem_storage.go

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

* Update repo/blob/filesystem/filesystem_storage.go

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

* blobtesting: fixed object_locking_map.go

* blobtesting: removed SetTime from ObjectLockingMap

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2021-12-18 14:00:20 -08:00
Jarek Kowalski
331c7f6298 epoch: changed how very slow index writes are handled (#1587)
Previously epoch manager would discard (on read) any index blobs
associated with epoch N written after epoch N+2 has already started.

There was no signal to the writer that the write is actually bad. This
change reports slow writes as a failure and disables read-time filtering.

This is important for repositories copied using sync-to because it
may not necessarily preserve the modification time leading to problems
with restore.
2021-12-15 07:06:28 -08:00
Jarek Kowalski
b81362d72c testing: do not run randomized tests in code coverage mode (#1585) 2021-12-13 22:07:50 -08:00
Jarek Kowalski
081c252e18 blobtesting: refactored fault injection into fluent API (#1578) 2021-12-13 11:11:43 -08:00
Shikhar Mall
2857c4831a storage api put-blob retention options (#1511)
* storage api put-blob retention options

Co-authored-by: Shikhar Mall <shikhar@kasten.io>
2021-11-15 19:46:42 -08:00