Commit Graph

423 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
Jarek Kowalski
a5d689eb36 ui: Added test to verify #1057 (#1526) 2021-11-20 11:43:03 -08:00
CrendKing
2394b420b0 Change Mbit/s units to MB/s (base-10) (#1522) 2021-11-18 15:41:40 -08:00
Jarek Kowalski
62edab618f throtting: implemented a Throttler based on token bucket and configur… (#1512)
* throtting: implemented a Throttler based on token bucket and configurable window.

* cli: rewired throttle options to use common Limits structure and helpers

The JSON is backwards compatible.

* blob: remove explicit throttling from gcs,s3,b2 & azure

* cleanup: removed internal/throttle

* repo: add throttling wrapper around storage at the repository level

* throttling: expose APIs to get limits and add validation

* server: expose API to get/set throttle in a running server

* pr feedback
2021-11-16 07:39:26 -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
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
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
e41c53b01b server: ensure all HTTP requests are processed in a detached context (#1495) 2021-11-06 17:35:57 -07:00
Jarek Kowalski
03def8f33a server: maintenance in newly-created repo (#1494)
The issue in #1439 was caused by goroutine context being associated
with the HTTP request so it became canceled soon after the request was
over, thus the goroutine to run maintenance never ran.

Fixed by adding ctxutil.Detach()

Also fixed logging by passing top-level contexts to requests
and added --log-server-requests flag to `server start` which enables
request logging.
2021-11-06 17:10:53 -07:00
Jarek Kowalski
669b8515e1 epoch: eliminate redundant ListBlobs() calls in epoch.Manager (#1492) 2021-11-06 16:44:45 -07:00
Jarek Kowalski
0b737c170d maintenance: improved scheduling (#1493)
Instead of attempting maintenance every 10 minutes we will do a longer
sleep until the predicted next maintenance time (or 4 hours, whichever
is shorter).

Related #1439
2021-11-06 16:44:27 -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
2a6140d82f fixed directory read race condition (#1489)
This was introduced by a refactoring in #1361 - unlike
ioutil.ReadDir() which internally handles list/delete race and always
returns os.FileInfo, Info() on os.DirEntry can fail if a file
is deleted right after listing it.

Fixes #1486
2021-11-05 10:18:03 -07:00
Eng Zer Jun
c3f4c41591 refactor: move from ioutil.ReadDir to os.ReadDir (#1361)
* refactor: move from ioutil.ReadDir to os.ReadDir

This commit is an addition to PR #1360. According to
`ioutil.ReadDir` documentation (https://pkg.go.dev/io/ioutil#ReadDir),
`os.ReadDir` should be preferred as it is a more efficient and correct
implementation.

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

* perf: optimize localfs scan performance

Reference: https://github.com/kopia/kopia/pull/1361#issuecomment-937345195
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-11-04 16:57:24 -07:00
Jarek Kowalski
a0cfa2556f introduced structural debug logging and optional JSON output (#1475)
* logging: added Logger.Debugw(message, key1, value1, ..., keyN, valueN)

This is based on ZAP and allows structural logs to be emitted.

* cli: added --json-log-console and --json-log-file flags

* logging: updated storage logging wrapper to use structural logging

* pr feedback
2021-11-03 21:57:37 -07:00
Julio Lopez
0aaa5f901f nit: use strings.Replacer (#1476) 2021-11-03 16:39:48 -07:00
David Zaninovic
540910e854 Use blob.OutputBuffer in blob.Reader interface instead of internal gather.WriteBuffer (#1452)
* Use blob.OutputBuffer in blob.Reader interface instead of internal gather.WriteBuffer

* blob: remove blob.Storage.OutputBuffer methods Append() and ToByteSlice()

(cherry picked from commit 36d30b3b5f1f916e95493ca7552e6612f56624a6)

Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2021-11-03 11:58:49 -07:00
Jarek Kowalski
0d0f48a7ee clock: discard monotonic clock component in clock.Now() (#1437)
The dual time measurement is described in
https://go.googlesource.com/proposal/+/master/design/12914-monotonic.md

The fix is to discard hidden monotonic time component of time.Time
by converting to unix time and back.

Reviewed usage of clock.Now() and replaced with timetrack.StartTimer()
when measuring time.

The problem in #1402 was that passage of time was measured using
the monotonic time and not wall clock time. When the computer goes
to sleep, monotonic time is still monotonic while wall clock time makes
a leap when the computer wakes up. This is the behavior that
epoch manager (and most other compontents in Kopia) rely upon.

Fixes #1402

Co-authored-by: Julio Lopez <julio+gh@kasten.io>
2021-10-22 15:35:09 -07:00
Jarek Kowalski
fa2a931891 ui: fixed the refresh button in source list (#1428) 2021-10-20 06:58:37 -07:00
Jarek Kowalski
3a40cc621f epoch: do not fail on moving deletion watermark backwards (#1422)
This is a legitimate possiblity if someone uses `--safety=none` followed
by regular maintenance.

Fixes #1312
2021-10-19 08:17:58 -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
d5c619f98d epoch: additional logging to get to the bottom of #1402 (#1417) 2021-10-18 22:39:18 -07:00
Jarek Kowalski
24d8eb75da epoch: increase epoch time and cleanup safety margin (#1407)
Reduces likelihood of #1402 until we fix the root cause.
2021-10-17 22:31:56 -07:00
Jarek Kowalski
7f98c49edc epoch: when doing background compaction and cleanup work, ignore cancelation signal (#1406)
This would frequently prevent the actual compaction from being done
leading to performance degradation.
2021-10-17 20:14:25 -07:00
Jarek Kowalski
191a51b278 ui: fixed snapshotting UNC roots (#1401)
This was caused by additional resolution of path names only done in UI,
which caused \\hostname\share to be treated as relative and resolved
against the home directory.

Fixes #1385
Fixes #1362
2021-10-17 13:25:12 -07:00
Jarek Kowalski
fba0956795 logging: fixed logging from parallel work queue (#1388)
Fixes #1387
2021-10-14 07:14:46 -07:00
Jarek Kowalski
b7a4fa56bf retry: abort retry loop on context errors (#1383)
Fixes #1377
2021-10-13 19:10:02 -07:00
Jarek Kowalski
7ba2132b97 logging: fixed console timestamps to be local time, more nits (#1381) 2021-10-13 08:54:57 -07:00
Jarek Kowalski
4a47bc3210 logging: switched from go-logging to zap (#1376)
This is much more efficient in terms of memory allocations
and speeds up backup due to less GC pressure.

Fixes #1345
2021-10-12 22:52:24 -07:00
Z
33c8733750 add unicode filename test, add env switches for long filenames/unicode filenames, update workflow file to include env variables (#1371) 2021-10-09 12:38: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
3bb5b63289 sftp: fixed performance reggression due to connection management (#1359)
* sftp: fixed performance reggression due to connection management

The previous pooling was causing serialization of all requests, which
was too slow.

This change effectively reverts connection pooling but adds
automatic reconnection + unit tests.

* sftp: fixed unwanted retry on initial connection
2021-10-06 07:28:42 -07:00
Jarek Kowalski
aa44b70866 mount: fixed mounting of directories w/symlinks over WebDAV (#1358)
Directories containing symlinks could not be mounted on Windows and
were failing with 'invalid parameter'.

This change skips those entries and emits a warning to the console.

Symlinks appear to be unsupported in WebDAV at the protocol level
and servers usually follow symlinks server-side, which is not
feasible for Kopia. In the future we may be able to do more here, but
for now it's better to not show symlinks than not show anything.

Huge thanks to Joe Occhipinti for his help getting to the bottom of this
issue.
2021-10-05 21:23:08 -07:00
Jarek Kowalski
6b7c03bc97 deps: upgrade to github.com/golang-jwt/jwt/v4@4.1.0 and fixed linter (#1342) 2021-10-02 10:07:46 -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
792cc874dc repo: allow reusing of object writer buffers (#1315)
This reduces memory consumption and speeds up backups.

1. Backing up kopia repository (3.5 GB files:133102 dirs:20074):

before: 25s, 490 MB
after: 21s, 445 MB

2. Large files (14.8 GB, 76 files)

before: 30s, 597 MB
after: 28s, 495 MB

All tests repeated 5 times for clean local filesystem repo.
2021-09-25 14:54:31 -07:00
Jarek Kowalski
d76cbcf47e cache: when cache validation fails, properly reset output buffer (#1295) 2021-09-16 05:35:54 -07:00
Jarek Kowalski
928150fe6b linter: upgrade to 1.42.1 (#1292) 2021-09-14 19:11:39 -07:00
Jarek Kowalski
bd7e9641da fixed minor buffer leak from internal logger, added allocation tracker (#1290) 2021-09-14 06:13:19 -07:00
Jarek Kowalski
8b2b91f9f9 content: fixed repo upgrade version (#1286)
* content: fixed repo upgrade version

Previously upgrade would enable epoch manager and index v2 but would
not set the version of the format itself. Everything worked fine
but it would not protect from old kopia opening the repository.

* ci: added compatibility test that uses real 0.8 and current binaries
2021-09-10 22:51:51 -07:00
Jarek Kowalski
d98b0edead endurance: rewrote test to be more stable (#1285) 2021-09-09 21:05:33 -07:00
Jarek Kowalski
7e68d8e4c1 Consolidated format version flags (#1284) 2021-09-08 18:44:03 -07:00
Jarek Kowalski
9cebffc628 Fix endurance test (#1254) 2021-08-27 04:22:18 -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
a203fa414d gather: MakeContiguous support for arbitrary chunk sizes (#1247) 2021-08-22 12:33:36 -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
Jarek Kowalski
bece46d5f6 logging: switched file log timestamps to be UTC by default, otherwise it's hard to correlate logs (#1240) 2021-08-07 20:18:03 -07:00