Commit Graph

271 Commits

Author SHA1 Message Date
Jarek Kowalski
dc964bee43 ui: Policy Editor - show effective value and definition point for policy fields (#1545)
* policy: resolve API for policy editor

* htmlui: enhanced Policy Editor UI to preview effective values
2021-11-30 21:40:41 -08:00
Jarek Kowalski
93930d20cb policy: revamped policy merge mechanism (#1538)
Added policy.Definition which allows us to precisely report where
each piece of policy came from.

Fixed a one-off bug with "noParent", which prevented merging of parent
policies one level too soon.

Added a whole bunch of merging helpers and generic reflection-based
test that ensures every single merge is tested.
2021-11-27 18:14:45 -08:00
Lukas Rieger
5224f79d7d [snapshot restore] use non-atomic writes (#1534)
* don't flush every file two times on snapshot restore
2021-11-26 13:10:44 -08:00
Jarek Kowalski
525720db95 cli: added 'snapshot pin' command (#1528) 2021-11-20 20:53:25 -08:00
Jarek Kowalski
cead806a3f blob: changed default shards from {3,3} to {1,3} (#1513)
* blob: changed default shards from {3,3} to {1,3}

Turns out for very large repository around 100TB (5M blobs),
we end up creating max ~16M directories which is way too much
and slows down listing. Currently each leaf directory only has a handful
of files.

Simple sharding of {3} should work much better and will end up creating
directories with meaningful shard sizes - 12 K files per directory
should not be too slow and will reduce the overhead of listing by
4096 times.

The change is done in a backwards-compatible way and will respect
custom sharding (.shards) file written by previous 0.9 builds
as well as older repositories that don't have the .shards file (which
we assume to be {3,3}).

* fixed compat tests
2021-11-16 06:02:04 -08:00
Jarek Kowalski
8a4ac4dec3 Upgraded linter to 1.43.0 (#1505)
* fixed new gocritic violations
* fixed new 'contextcheck' violations
* fixed 'gosec' warnings
* suppressed ireturn and varnamelen linters
* fixed tenv violations, enabled building robustness tests on arm64
* fixed remaining linux failures
* makefile: fixed 'lint-all' target when running on arm64
* linter: increase deadline
* disable nilnil linter - to be enabled in separate PR
2021-11-11 17:03:11 -08:00
Jarek Kowalski
e9303cec8d upload: avoid reporting ignored entries twice (#1506)
Previously ignored entries were reported from the estimate goroutine
and from the main upload goroutine doubling each ignored counter in
the UI.
2021-11-09 08:39:47 -08:00
Jarek Kowalski
89edfbf257 maintenance: send logs to content log as well (#1496) 2021-11-06 23:08:00 -07:00
Jarek Kowalski
dcff6c285d Added support for logging policies (#1472)
* policy: introduced OptionalBool - refactoring

* policy: added logging policy

* testing: added support for symlinks and modtime to mockfs

* logging: exposed NullLogger instance

* upload: emit debug logs according to logging policies

* cli: logging policy support
2021-11-06 10:06:05 -07:00
Jarek Kowalski
c8c433fb60 cli: when migrating snapshot honor destination policies (#1433)
In particular this applies compression based on destination repository
policies.

By default ignore rules are disabled during migration to preserve all
files, but that can be optionally enabled using '--apply-ignore-rules'.

Fixes #1429
2021-10-21 22:12:06 -07:00
Jarek Kowalski
789a739a5b server: fixed next snapshot time computation (#1418)
Fixes #1405

Moved logic to SchedulingPolicy, added unit tests.
2021-10-18 22:55:11 -07:00
Jarek Kowalski
e96ddc6105 upload: fix ignoring files after action redirects snapshot directory (#1409)
Fixes #1399
Fixes #1346
2021-10-17 23:02:00 -07:00
Jarek Kowalski
64af1396f6 mount: fixed name escaping and added disambiguation (#1403)
Fixes #1400
Fixes #1050
2021-10-17 16:32:54 -07:00
Jarek Kowalski
d9e0723fe4 actions: expose KOPIA_ACTION and KOPIA_VERSION environment variables (#1398)
Fixes #1394
2021-10-17 11:59:36 -07:00
Jarek Kowalski
8b760b66a8 logging: added memoization of Logger instances per context (#1369) 2021-10-09 05:02:18 -07:00
Eng Zer Jun
73e492c9db refactor: move from io/ioutil to io and os package (#1360)
* refactor: move from io/ioutil to io and os package

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* chore: remove //nolint:gosec for os.ReadFile

At the time of this commit, the G304 rule of gosec does not include the
`os.ReadFile` function. We remove `//nolint:gosec` temporarily until
https://github.com/securego/gosec/pull/706 is merged.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-06 08:39:10 -07:00
Jarek Kowalski
d60d33bda5 upload: memory usage and speed improvements (#1336)
* upload: do not launch error group when doing non-parallel upload

* encryption: refactored code to reduce slice allocation, this uncovered a minor subtle bug in index recovery due to manual memory management

* content: fixed use-after-free bug during index recovery that started failing test after encryption memory management improvements

* gather: tweaked retention and chunk sizes

* gather: added typicalContiguousAllocator with 8MB chunks for default configuration
2021-10-01 22:57:37 -07:00
Jarek Kowalski
6d40d2b7ad ui: Added UI options to select shallow restore options (#1301) 2021-09-19 09:57:26 -07:00
Jarek Kowalski
928150fe6b linter: upgrade to 1.42.1 (#1292) 2021-09-14 19:11:39 -07:00
Jarek Kowalski
7e68d8e4c1 Consolidated format version flags (#1284) 2021-09-08 18:44:03 -07:00
Jarek Kowalski
740741921b maintenance: check for clock skew at the beginning of maintenance (#1253)
* testing: use in-memory blob.Storage for repotesting

* maintenance: check for clock skew at the beginning of maintenance
2021-08-26 18:29:34 -07:00
Jarek Kowalski
9e182f131a linter: upgraded to 1.42.0 (#1246) 2021-08-20 18:26:45 -07:00
Jarek Kowalski
35d0f31c0d huge: replaced the use of allocated byte slices with populating gather.WriteBuffer in the repository (#1244)
This helps recycle buffers more efficiently during snapshots.
Also, improved memory tracking, enabled profiling flags and added pprof
by default.
2021-08-20 08:45:10 -07:00
abba23
6205b55601 Fix weekly retention labels not being assigned correctly (#1211)
* Fix weekly retention labels not being assigned correctly

This should resolve #814.

* Add test for weekly retention label assignment
2021-07-26 07:19:59 -07:00
Benedikt McMullin
317d5c3419 force-hash: Allow fractional percentages (#1209)
* force-hash: Allow fractional percentages

Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2021-07-24 09:45:46 -07:00
Jarek Kowalski
9e059a1277 upgraded linter to 1.41.0 (#1144) 2021-06-16 19:44:55 -07:00
Robert Kroeger
93979818e6 Add a flag to not shallowrestore small files (#1126)
When doing a shallow restore, small files might take up less size than
storing the DirectoryEntry metadata. Add a minimum file size flag that
where files below that size will be written directly instead being
represented with shallow placeholders. This improves on #710.
2021-06-09 20:31:07 -07:00
Robert Kroeger
6fc3bf1af6 Support for shallow restore (#725) 2021-06-08 20:11:43 -07:00
Jarek Kowalski
4b251bdaac mechanical: added ctx parameter to repo.{Direct}WriteSession callback (#1114) 2021-06-02 23:12:30 -07:00
Jarek Kowalski
5179ad2cd2 cli: test + misc improvements (#1083)
* cli: Added --max-examples-per-bucket flag to 'kopia snapshot estimate'

Added and cleaned up a bunch of unit tests.

Fixes #1054

* cli: misc tests to increase code coverage of the cli package

* ci: move code coverage run into separate GH job
2021-05-17 21:47:11 -07:00
Jarek Kowalski
30ca3e2e6c Upgraded linter to 1.40.1 (#1072)
* tools: upgraded linter to 1.40.1

* lint: fixed nolintlint vionlations

* lint: disabled tagliatele linter

* lint: fixed remaining warnings
2021-05-15 12:12:34 -07:00
Sirish Bathina
dd41296f2a Tagging of kopia snapshots and listing of snapshots by tag (#1030) 2021-04-30 06:16:19 -07:00
Jarek Kowalski
df430371b9 Refactored content.Info to be an interface and switched index parsing to be lazy (#1008) 2021-04-27 05:53:52 -07:00
Jarek Kowalski
069299f21d Policy path validation (#1006)
* policy: added path validation to disallow non-root paths ending with slash or backslash

* ui: unified error alerts
2021-04-21 23:04:03 -07:00
teepr
d235672ea0 Remove "KB" label from processed files count (#991) 2021-04-18 08:36:32 -07:00
Jarek Kowalski
2062c07259 mechanical field renames (#988)
* content: mechanical rename content.Info.Length -> content.Info.PackedLength
* server: renamed grpc API ContentInfo.length->packed_length (non-breaking)
2021-04-16 22:42:32 -07:00
Denis Fondras
2b6af55142 Allow to compile Kopia cli on OpenBSD (#983)
* allow to compile Kopia cli on OpenBSD
2021-04-13 12:45:04 -07:00
Jarek Kowalski
85aa5e67f2 build: added freebsd build (untested) with FUSE mounting disabled (#964)
* build: added freebsd build (untested) with mounting disabled until go-fuse has it

* renamed freebsd package names to include 'experimental'
2021-04-12 20:16:00 -07:00
Jarek Kowalski
f95b1c5b52 maintenance: tweaked log output (#957) 2021-04-09 21:43:32 -07:00
Jarek Kowalski
cbb29f4ef3 maintenance: fixed possible starvation of full blob deletion by quick maintenance (#955)
* testing: added test that simulates running auto maintenance over several weeks of time.

This ensures all maintenance tasks run with reasonable frequency.

* testing: modify time interval to 30 minutes which uncovered a bug where we're starving full blob deletion

* maintenance: fixed full rewrite logic to allow full rewrite after a quick rewrite

* maintenance: when performing quick maintenance after full maintenance we sometimes need to do full blob deletion to ensure liveness

* maintenance: refactored to improve readability
2021-04-09 19:15:03 -07:00
Jarek Kowalski
f4347886b8 logging: simplified log levels (#954)
Removed Warning, Notify and Fatal:

* `Warning` => `Error` or `Info`
* `Notify` => `Info`
* `Fatal` was never used.

Note that --log-level=warning is still supported for backwards
compatibility, but it is the same as --log-level=error.

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-04-09 07:27:35 -07:00
Jarek Kowalski
81990b89cc improved maintenance safety (#946)
* maintenance: refactored code by introducing TaskType constants
* maintenance: added additional safety rules for DeleteUnreferencedBlobs and RewriteContents

* DeleteUnreferencedBlobs will run if now() > time(last-content-rewrite) + 1h
  (this ensures other kopia clients will have time refresh their indexes
  to the rewritten blobs before we delete them)

* RewriteContents runs only if time(last-blob-deletion) > time(last-content-rewrite)
  (this makes sure we don’t starve blob deletions if somebody runs
  maintenance too frequently)

With those two rules in place each maintenance cycle will effectively
do either RewriteContents or DeleteUnreferencedBlobs but not both
(except when --safety=none).
2021-04-08 22:31:15 -07:00
Jarek Kowalski
b8c3ae378b testing: replaced locally-defined must() with require.NoError() (#942) 2021-04-05 09:57:50 -07:00
Jarek Kowalski
d07eb9f300 cli: added --safety=full|none flag to maintenance commands (#912)
* cli: added --safety=full|none flag to maintenance commands

This allows selection between safe, high-latency maintenance parameters
which allow concurrent access (`full`) or low-latency which may be
unsafe in certain situations when concurrent Kopia processes are
running.

This is a breaking change for advanced CLI commands, where it removes
timing parameters and replaces them with single `--safety` option.

* 'blob gc'
* 'content rewrite'
* 'snapshot gc'

* pr renames

* maintenance: fixed computation of safe time for --safety=none

* maintenance: improved logging for blob gc

* maintenance: do not rewrite truly short, densely packed packs

* mechanical: pass eventual consistency settle time via CompactOptions

* maintenance: add option to disable eventual consistency time buffers with --safety=none

* maintenance: trigger flush at the end of snapshot gc

* maintenance: reload indexes after compaction that drops deleted entries, this allows single-pass maintenance with --safety=none to delete all unused blobs

* testing: allow debugging of integration tests inside VSCode

* testing: added end-to-end maintenance test that verifies that full maintenance with --safety=none removes all data
2021-04-02 21:56:01 -07:00
Jarek Kowalski
8beb265c27 nit: output snapshot ID when --json is used (#921) 2021-04-02 19:58:17 -07:00
Jarek Kowalski
9a756c719f Enabled race detector in CI, fixed a few data races (#919)
* content: fixed data race in IterateUnreferencedBlobs

* upload: fixed data race between uploader and estimator

* testing: fixed data race in repo/blob/logging test

* makefile: run tests on CI/linux/amd64 with -race

* robustness: fixed test race

* content: fixed data race getContentDataUnlocked that triggers TestParallelWrites - looks scary but in practice very hard to trigger in real life and does not cause data corruption

* testing: reduce test complexity under race detector

* server: fixed minor race in refreshStatus()

* testing: reduced depth of sharedTestDataDir2

* ci: run race detector in separate job

* ci: run unit test race detector in parallel to integration tests
2021-04-02 18:21:04 -07:00
Jarek Kowalski
2c2c9d52e0 nit: refactored repetitive reportesting setup code (#916) 2021-03-29 14:52:14 -07:00
Jarek Kowalski
74833cefcb cli: added standard --json flags to several commands (#910)
* cli: added standard --json flags to several commands

Fixes #272

* Update flag description

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-03-25 17:55:18 -07:00
Jarek Kowalski
cbcd59f18e Added repository user authorization support + server flag refactoring + refresh (#890)
* nit: replaced harcoded string constants with named constants

* acl: added management of ACL entries

* auth: implemented DefaultAuthorizer which uses ACLs if any entries are found in the system and falls back to LegacyAuthorizer if not

* cli: switch to DefaultAuthorizer when starting server

* cli: added ACL management

* server: refactored authenticator + added refresh

Authenticator is now an interface which also supports Refresh.

* authz: refactored authorizer to be an interface + added Refresh()

* server: refresh authentication and authorizer

* e2e tests for ACLs

* server: handling of SIGHUP to refresh authn/authz caches

* server: reorganized flags to specify auth options:

- removed '--allow-repository-users' - it's always on
- one of --without-password, --server-password or --random-password
  can be specified to specify password for the UI user
- htpasswd-file - can be specified to provide password for UI or remote
  users

* cli: moved 'kopia user' to 'kopia server user'

* server: allow all UI actions if no authenticator is set

* acl: removed priority until we have a better understood use case for it

* acl: added validation of allowed labels when adding ACL entries

* site: added docs for ACLs
2021-03-18 23:03:27 -07:00
Jarek Kowalski
132e2eef50 New snapshot UX - streamlined snapshot creation and policy setting (#878)
* uitask: added support for reporting string progress info

* server: report current directory as task progress

* snapshot: created reusable Estimate() method to be used during upload, cli estimate and via API

* cli: switched to snapshotfs.Estimate()

* server: added API to estimate snapshot size

* kopia-ui: fixed directory selector

* htmlui: streamlined new snapshot flow and cleaned up policy setting

See https://youtu.be/8p6csuoB3kg
2021-03-10 23:04:55 -08:00