Commit Graph

232 Commits

Author SHA1 Message Date
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
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
51de24dcff refactor(snapshots): refactored uploader into separate package (#4450) 2025-03-14 15:48:31 -07:00
Julio López
3fbe0bd424 fix(server): prevent maintenance task on read-only repos (#4408)
Avoid starting a maintenance task on the server when
the repository connection (configuration) is read-only.

Also:
* Check for read-only repo before running maintenance.
* Move direct repo check to startMaintenanceManager.
* Rename function as maybeStartMaintenanceManager.
  The name reflects that the function may not start a
  maintenance task manager.
* Add connect options to repotesting.
* Add test for maintenance on read-only repo.

- Fixes: #4373
2025-02-13 20:13:22 -08:00
Jarek Kowalski
d6b9254a4c feat(notifications): emit snapshot report notifications in the UI/server (#4323)
* feat(notifications): emit snapshot report notifications in the UI/server

* added test

* fixed data race
2024-12-30 10:59:11 -08:00
Jarek Kowalski
c1757a0c67 feat(general): misc notifications improvements (#4319)
* feat(general): various notifications improvements

* added API to test notification profiles
* added --http-header to webhook notification configuration
* refactored configuration to always apply defaults before persisting options in the repository
* added 'notification profile show --profile-name=X' command

* more tests

* more test coverage

* report notification code coverage
2024-12-29 09:50:20 -08:00
Jarek Kowalski
75e844d21f feat(server): only log successful authentication events when --log-server-requests is enabled (#4296) 2024-12-07 11:18:17 -08:00
Linus
a0c5e57e4a Add logging of failed and successful login attempts (#4234)
for monitoring, troubleshooting, and to allow using tools like crowdsec or fail2ban
2024-11-11 18:46:07 -08:00
Jarek Kowalski
afb85cbb34 feat(cli): send error notifications and snapshot reports (#4233)
* feat(cli): send error notifications and snapshot reports

Notifications will be sent to all configured notification profiles
according to their severity levels.

The following events will trigger notifications:

- Snapshot is created (CLI only, severity >= report)
- Server Maintenance error occurs (CLI, server and UI, severity >= error)
- Any other CLI error occurs (CLI only, severity >= error).

A flag `--no-error-notifications` can be used to disable error notifications.

* added template tests

* improved time formatting in templates

* plumb through notifytemplate.Options

* more testing for formatting options

* fixed default date format to RFC1123
2024-11-11 17:53:50 -08:00
Eugene Sumin
f0541ab67e feat(cli): introduce adaptive estimation mechanism (#4218)
* Add rough estimation mechanism

* Extract data size estimation scan to standalone function

* Introduce estimation type flag

* Change signature of EstimatedDataSize

* Extract estimation logic and test it

* Adjust err handling in GetVolumeSizeInfo

* Make GetVolumeSizeInfo reusable

* Fix type issue for windows platform

* Use adaptive estimation with threshold
2024-11-04 17:31:09 -08: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
Jarek Kowalski
58bcb29d1a feat(server): added API to manipulate notification profiles in the UI (#4171) 2024-10-14 10:16:08 -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
Jarek Kowalski
ac446a2d16 chore(ci): upgraded linter to 1.60.3 (#4086)
* silenced several 'gosec' findings
2024-09-03 21:29:56 -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
fcb8197f3f chore(ci): upgraded linter to 1.59.0 (#3883) 2024-05-29 20:31:57 -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
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
123927d573 fix(server): fixed deadlock between server and scheduler during shutdown (#3782) 2024-04-09 22:37:50 -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
Jarek Kowalski
7278f570e2 chore(ci): upgraded linter to 1.57.1 (#3753) 2024-03-25 22:20:38 -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
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
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
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
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
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
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
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
Jarek Kowalski
cb98abbc2c feat(snapshots): added ability to use cron expressions to schedule snapshots (#3149)
* feat(snapshots): added ability to use cron expressions to schedule snapshots

We use `github.com/hashicorp/cronexpr` to parse and evaluate expressions,
as documented in https://github.com/hashicorp/cronexpr#implementation

* upgrade ui

* pr feedback
2023-07-19 19:26:17 -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
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
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
Edward Betts
1e97574391 fix(general): correct spelling mistakes (#2684) 2023-01-21 07:37:15 -08: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
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
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
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
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
7bda16ab33 feat(repository): introduced fs.UTCTimestamp (#2343)
Fixes #2342
2022-09-02 10:35:59 -07:00