Commit Graph

840 Commits

Author SHA1 Message Date
ashmrtn
30079e4077 feat(repository): role assumption for S3 storage (#4182)
* Use an AssumeRole credential provider if a role was specified
* Use minio's assumerole call
* Update assume role test

---------

Co-authored-by: Vaibhav Kamra <vkamra@alcion.ai>
2025-04-30 22:49:33 -07:00
Julio Lopez
c27c5e8c05 refactor(provider): change StartupTimeout type to Duration (#4528)
This allows persisting and reading back the timeout as a duration.

There are be no backwards compatibility issues, since the field is
not currently set, so it is not persisted in the configuration file.
2025-04-30 15:59:43 -07:00
Julio Lopez
2d9b7f1e33 feat(providers): Azure Blob client certificate authentication (#4535)
Allow the use of a client certificate when authenticating
to an Azure Blob storage provider.

Tests included.

Credit: @DeepikaDixit

Authored-by: Deepika Dixit <DeepikaDixit@users.noreply.github.com>
2025-04-29 23:47:41 -07:00
Julio Lopez
8098f49c90 chore(ci): remove exclusion for unused ctx parameters (#4530)
Remove unused-parameter exclusion for `ctx` in revive linter.

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 23:11:36 -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
b0827d128a fix(ci): remove gocritic unnecessaryDefer exclusion (#4525)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-25 14:47:08 -07:00
Julio López
09b88d3860 chore(general): minor cleanups and other nits (#4507)
* use uint8 for clarity
* unexport writeContentAsyncAndVerify
* fix typo in test function name
* remove commented interface functions
* use atomic.Int32
* cleanups in socket server activation test
* leverage stdlib's maps and slices packages
  replace uses of `golang.org/x/exp/maps`
* nit: leverage `maps.Values`
2025-04-16 23:25:01 -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
Julio López
f831def52a build(cli): set build info version and info when not set (#4498)
Sets `repo.BuildInfo` and `repo.BuildVersion` when they are
not specified via link flags.

The behavior for binaries built via CI and Make remains the same.

Sets `repo.Version` to `v0-unofficial` during tests.
2025-04-12 14:51:32 -07:00
Julio López
9af84ae60a chore(general): reduce verbosity for noisy log message (#4357)
Changes the log level from ERROR to DEBUG

Signed-off-by: Pavel Larkin <pavel.larkin@veeam.com>
Co-authored-by: Pavel Larkin <laxkin@gmail.com>
2025-01-22 12:30:42 -08:00
dependabot[bot]
5ec112eb38 build(deps): bump github.com/minio/minio-go/v7 from 7.0.82 to 7.0.83 in the common-golang-dependencies group (#4337)
* build(deps): bump github.com/minio/minio-go/v7

Bumps the common-golang-dependencies group with 1 update: [github.com/minio/minio-go/v7](https://github.com/minio/minio-go).


Updates `github.com/minio/minio-go/v7` from 7.0.82 to 7.0.83
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](https://github.com/minio/minio-go/compare/v7.0.82...v7.0.83)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: common-golang-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* fixed the build

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2025-01-11 13:49:17 -08:00
Jarek Kowalski
b60cac4860 fix(cli): fixed v0.18.0 failures using v0.17.0-generated config (#4255)
This was caused by the client using key derivation algorithm
from a config file (which did not have it when it was generated
using old version of Kopia).

Fixes #4254
2024-11-17 10:15:00 -08:00
Jarek Kowalski
eb1cf64c27 chore(ci): upgraded linter to 1.62.0 (#4250) 2024-11-16 07:16:50 -08:00
Jarek Kowalski
91d00e8256 feat(providers): upgraded rclone to 1.68.2, fixed Google Drive rclone compatibility (#4249)
* chore(ci): upgrade rclone to 1.68.2

* fix(providers): fixed Google Drive rclone compatibility
2024-11-15 20:02:08 -08:00
Julio López
a3c570d264 refactor(providers): simplify GCS client construction (#4120)
Changes:
* simplify GCS client creation;
* early parameter validation in `gcs.New()`;
* remove GCS internal tests;
* remove no-longer used GCS creds helpers.
2024-10-27 18:39:45 -07:00
Julio López
966bb3db94 test(general): cleanup index builder tests (#4197)
Objective: make it easier to understand the tests

Changes:

- Introduce helpers to simplify the tests and increase clarity.
  * verifySortedEntries
  * addDeterministicContents 
  * addContentIDsWithDifferentPrefixes
  * addIntsAsDeterministicContent 
- Rename tests to better convey what they are testing.
- Use rand.Perm for simplicity

Ref: #4139
2024-10-24 18:57:54 -07:00
chavacava
60496829d0 removes unreachable code (#4195) 2024-10-24 17:33:17 -07:00
Prasad Ghangal
3bf947d746 feat(repository): Metadata compression config support for directory and indirect content (#4080)
* Configure compressor for k and x prefixed content

Adds metadata compression setting to policy
Add support to configure compressor for k and x prefixed content
Set zstd-fastest as the default compressor for metadata in the policy
Adds support to set and show metadata compression to kopia policy commands
Adds metadata compression config to dir writer

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Pass concatenate options with ConcatenateOptions struct

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Move content compression handling to caller

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Move handling manifests to manifest pkg

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Correct const in server_test

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Remove unnecessary whitespace

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Disable metadata compression for < V2 format

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

---------

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>
2024-10-23 23:28:23 -07:00
Mike McKay-Dirden
e20ec3d290 fix(repository): Allow extending blob retentions (#4151) 2024-10-23 18:46:51 -07:00
Julio López
f5b023a5a4 test(general): add helpers to simplify tests (#4191)
* move common functionality into `verifyEpochTaskRanInQuickMaintenance` helper
* add `verifyEpochManagerIsEnabled` helper
* add `setRepositoryOwner` helper
* rename helper
2024-10-22 12:26:58 -07:00
Julio López
90c4a3c978 fix(general): run epoch maintenance for quick maintenance (#4185)
Changes:

* test that quick maintenance runs when epoch manager is enabled

* fix(general): run epoch maintenance for quick maintenance
  Change based on a known-to-be-safe portion of the changes proposed in #3901

* cleanup: pass epoch manager to `runTaskEpochMaintenanceQuick`
The caller needs to get the epoch manager to determine
whether or not the epoch manager is enabled. The caller
now passes the epoch manager to `runTaskEpochMaintenanceQuick`

* wrap the error inside runTaskEpochMaintenanceQuick
2024-10-21 12:06:50 -07:00
Julio López
65b48433db refactor(general): include clock skew in error message (#4186)
* nit: include clock skew in error message
* nit: un-capitalize error message.
2024-10-18 22:28:12 -07:00
Julio López
98290b9ed7 refactor: make toJSON a test helper (#4184) 2024-10-18 16:12:18 -07:00
Julio López
d7a26b3499 test(general): prefer require (#4183)
No functional changes to the tests
2024-10-18 10:15:10 -07:00
lyndon-li
699e0386b4 refactor(repository): follow up changes for PR 4139 (#4167) 2024-10-15 14:05:42 +00:00
lyndon-li
a848ab98e5 refactor(repository): Reduce memory usage for epoch index compaction (#4139)
* index builder for epoch index compaction

* index builder for epoch index compaction: fix CI errors

* index builder for epoch index compaction: UT for OneUseBuilder

* index builder for epoch index compaction: fix CI errors

* index builder for epoch index compaction: use *Info as builder item

* index builder for epoch index compaction: fix CI errors

* index builder for epoch index compaction: fix CI errors

* index builder for epoch index compaction: fix CI errors
2024-10-09 18:43:09 -07:00
ashmrtn
9a507b73d5 refactor(repository): Reduce memory allocations during manifest compaction (#4084)
* Change struct for tracking committed content

Committed content only ever has a value of 'true' for committed so use
an empty struct and an existance check instead.

* Don't copy committed manifest set for compaction

Assuming the number of committed manifests is much larger than the
number of manifest updates, it seems reasonable to update the logic to
write manifests out to not delete entries from the set being operated
on. Doing so allows us to avoid creating a duplicate of the set of all
committed manifests during compaction, which could also save some memory
as the temporary map wasn't being right-sized based on the the number of
committed entries. This also works because writing data either fails or
succeeds completely. That means there's no possibility of only some
entries being written out but not others, which means callers can use
the presence of an error to determine how to react (i.e. clear pending
set).

* Benchmarks for compaction
2024-10-09 18:41:13 -07:00
Jarek Kowalski
c0bd372d29 feat(cli): support for defining notification profiles and templates via CLI (#4034)
* feat(cli): support for defining notification profiles via CLI

Profile management:

```
$ kopia notification profile configure email \
    --profile-name=X \
    --smtp-server=smtp.gmail.com \
    --smtp-port=587 \
    --smtp-username=X \
    --smtp-password=X \
    --mail-from=X \
    --mail-to=X \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile configure pushover --profile-name=X \
    --user-key=X \
    --app-token=X \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile configure webhook --profile-name=X \
    --endpooint=http://some-address:port/path \
    --method=POST|PUT \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile test --profile-name=X

$ kopia notification profile delete --profile-name=X

$ kopia notification profile list
```

Template management:

```
$ kopia notification template show X

$ kopia notification template set X \
   --from-stdin | --from-file=X | --editor

$ kopia notification template remove X

$ kopia notification template list

```

Implements #1958

* additional refactoring for testability, various naming tweaks
2024-10-06 16:28:39 +00:00
Julio López
63f227386f refactor(general): levarage stdlib's context.WithoutCancel(ctx) (#4159)
Removes `internal/ctxutil` package with equivalent implementation
2024-10-06 09:05:26 -07: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
8ce8245f32 test(providers): cleanup GCS tests (#4138)
* use `getEnvVarOrSkip()` helper
* use creds from JSON env for test to actually run the test
* prefer require
* nit: relocate helpers
* fail tests if credentials cannot be decoded
2024-09-27 10:24:16 -07:00
Julio López
97b0c02e36 fix(providers): GCS tests (#4136)
* `getCredJSONFromEnv` helper
* use `getCredJSONFromEnv`
* `getEnvVarOrSkip` helper
* skip GCS immutable tests if bucket name is not provided
2024-09-26 22:22:10 -07:00
Julio López
b60804198c refactor(provider): always clone default HTTP transport in S3 provider (#4132)
The s3 storage provider had a different http transports for different cases:

- https without TLS verification: `&http.Transport{}` with default values;
- https with TLS verification: `http.DefaultTransport.Clone()`

This change uses `http.DefaultTransport` in all cases, instead of creating an
empty (zero-value) `http.Transport` for consistency.

Authored-by: aleksandr.samarin (@alexvbg)
2024-09-26 21:51:07 -07:00
Mike McKay-Dirden
1bceb7155e feat(providers): GCS immutability (#4134)
- Allow blob `Put/ExtendBlobRetention`
- PITR support
- PITR/versioning tests
2024-09-26 21:46:25 -07:00
Julio López
3a9bafa366 refactor(general): rename repodiag.logWriteSyncer (#4109)
* refactor(general): clarify comments

* refactor(general): rename `repodiag.logWriteSyncer`

This name reflects:
- the function of the struct; and
- the interface it implements (`zapcore.WriteSyncer`)
2024-09-15 09:34:23 -07:00
Jarek Kowalski
8690f7a198 feat(cli): added option to configure maintenance listing parallelism (#4085)
Ref: #4038
2024-09-05 15:12:18 -07:00
Jarek Kowalski
ac446a2d16 chore(ci): upgraded linter to 1.60.3 (#4086)
* silenced several 'gosec' findings
2024-09-03 21:29:56 -07:00
ashmrtn
e7cf236310 test(repository): Ensure all manifest fields are populated (#4082)
Create a basic test that requires all manifest fields to be populated
and then checks if deserialization works as expected. This is meant to
help ensure tests stay updated across changes.
2024-08-31 13:21:47 -07:00
Julio López
948162dce5 refactor(general): minor miscellaneous cleanups (#4074)
Cleanups:

- use non-format variants of Log/Print with no additional args;
- fold in Fprintf call with no args into the following one;
- add missing arg placeholder in format strings;
- use require.Positive instead of Greater(..., 0);
- rename function to fillWithZeros to avoid collision with builtin clear;
- define type for context key to avoid collisions.
2024-08-25 22:10:46 -07:00
Julio López
6902738e0d fix(general): typo in error message (#4072) 2024-08-23 22:31:14 -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
Jarek Kowalski
e36fa78385 feat(snapshots): added support for per-directory splitter overrides (#3887)
This is useful when backing up directories that have giant files aligned
at MiB boundary, such as VM disk backups, etc.
2024-06-07 13:42:15 -07:00
Jarek Kowalski
fcb8197f3f chore(ci): upgraded linter to 1.59.0 (#3883) 2024-05-29 20:31:57 -07:00
Nick
4cf9582a49 test(server): Decompose base URL to URI to helper and add test (#3839)
Decompose the logic for parsing base URL into the URI for client dial.
Add a unit test for the new helper.
2024-05-02 18:01:28 +00:00
Mark Severson
3fcdb9b185 refactor(general): avoid using empty master keys (#3835)
Previously, empty master keys were passed to the underlying
cryptographic primitives (HKDF, AEAD, etc.).

While this worked because the authentication mechanisms returned an
error, it's best to avoid passing empty master keys to these primitives
in the first place. This refactor avoids passing empty master keys and
enforces this via an assertion in the key derivation function.
2024-05-01 14:50:01 -07:00
Julio López
f4b2034898 refactor(general): remove unused receiver (#3833)
No functional changes
2024-05-01 08:01:22 -07:00
Julio López
065e0adbfd refactor(general): make key derivers available in tests (#3826)
- Re-introduces the **insecure**, lightweight key deriver for
  testing **only**.
- Makes `scrypt` and `pbkdf2` derivers available in tests as well.
2024-04-30 17:21:11 -07:00
Nick
dc0dea4419 fix(cli): Fix client IPv6 URI generation for gRPC connections (#3830)
Connecting to gRPC repository API using an IPv6 address does not
correctly configure the URI for the client's dial. Reconstructing the
parsed URL into `hostname + ":" + port` will remove the square brackets
required for IPv6 addressing, resulting in a `too many colons in
address` error.

Fix the issue by instead using the helper `net.JoinHostPort()`, which
will add square brackets for IPv6 hostnames.

Tested by running `TestServer` with `httptest.serve` flag set, forcing
the test server to listen on the IPv6 loopback:
```
cd internal/server
go test -v -run=TestServer$ --httptest.serve=[::1]:0 ./server
```

Fails without fix:
```
    server_test.go:48: 
                Error Trace:    /workspaces/kopia/internal/server/server_test.go:48
                Error:          Received unexpected error:
                                failed to exit idle mode: invalid target address ::1:45373, error info: address ::1:45373:443: too many colons in address
```

Passes with fix:
```
--- PASS: TestServer (0.81s)
PASS
```
2024-04-29 19:32:59 -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
Julio López
2db8b20ed9 chore(general): rename files for consistency (#3825) 2024-04-26 14:47:36 -07:00