Commit Graph

1553 Commits

Author SHA1 Message Date
Jarek Kowalski
675bf4e033 Removed manifest manager refresh + server improvements (#835)
* manifest: removed explicit refresh

Instead, content manager is exposing a revision counter that changes
on each mutation or index change. Manifest manager will be invalidated
whenever this is encountered.

* server: refactored initialization API

* server: added unit tests for repository server APIs (HTTP and REST)

* server: ensure we don't upload contents that already exist

This saves bandwidth, since the client can compute hash locally
and ask the server whether the object exists before starting the upload.
2021-02-15 23:55:58 -08:00
Julio López
a622f86aec [trivial] reword comment and fix typo (#837) 2021-02-15 16:22:15 -08:00
Jarek Kowalski
fef23a7e2c disable code coverage 2021-02-14 21:45:56 -08:00
Jarek Kowalski
0b1d6d3159 codecov: run only on ubuntu 2021-02-14 21:18:09 -08:00
Jarek Kowalski
e2b6115762 codecov: removed manual upload 2021-02-14 21:17:01 -08:00
Jarek Kowalski
0581a07220 coverage: use GH action to upload coverage 2021-02-14 20:45:26 -08:00
Jarek Kowalski
2316257f72 coverage: changed filename 2021-02-14 20:40:36 -08:00
Jarek Kowalski
70b0d8d9c9 integrate with codecov.io (#836)
* integrate with codecov.io
2021-02-14 20:17:05 -08:00
Jarek Kowalski
5240f62e47 Auto shutdown fix (#834)
* server: removed auto-shutdown option

* server: added --shutdown-on-stdin which will shutdown server when stdin is closed. used by kopia-ui
2021-02-13 19:49:32 -08:00
Jarek Kowalski
81e0ecf2e1 testing: all logs to t.Logf() when the test fails (#833)
* testing: all logs to t.Logf() when the test fails

* testing: send server stderr to t.Logf()
2021-02-13 16:32:36 -08:00
Jarek Kowalski
de840547e6 Improved upload reporting (#832)
* blob: refactored upload reporting

Instead of plumbing this through blob storage context, we are passing
and explicit callback that reports uploads as they happen.

* htmlui: improved counter presentation

* nit: added missing UI route which fixes Reload behavior on the Tasks page
2021-02-13 10:51:11 -08:00
Jarek Kowalski
a655d7b9e2 minor build tweaks (#830) 2021-02-12 18:36:01 -08:00
Jarek Kowalski
4bf42e337d fix long filenames on Windows (#822)
* windows: fixed handling of long filenames
2021-02-12 09:09:42 -08:00
Jarek Kowalski
36fb13d0be fuse: switched to github.com/hanwen/go-fuse/v2 implementation (#829)
* fuse: switched to github.com/hanwen/go-fuse/v2 implementation

This supports latest MacFUSE (tested on 4.0.5 on Intel Mac).

* fuse: disabled direct IO which fixed macOS behavior

See https://github.com/hanwen/go-fuse/issues/390
2021-02-11 22:06:45 -08:00
Jarek Kowalski
504238df7a Restore UI (#823)
* server: added restore api
* htmlui: restore UI
2021-02-11 02:08:47 -08:00
Pavan Navarathna
c964e244f0 Support for ignoring sources when using snapshot create --all (#804)
* Add manual field to SchedulingPolicy
* CLI: Set and show for policy with manual field
* CLI: Edit policy support for manual field
* Check manual when creating snapshot for all source
* End to end test for snapshot create all
* Add UI option for setting Manual field
2021-02-10 21:59:06 -08:00
Nick
0e1c617045 Fix progress output string format (#828) 2021-02-10 11:18:52 -08:00
Jarek Kowalski
dc3d9f53a3 Added support for Tasks in the UI (#818)
* uitask: added package for managing and introspection into tasks running inside the process

* server: added API for getting details of tasks running inside the server

* htmlui: added new tab called 'Tasks'

This allows access to progres, logs and cancelation for long-running
tasks (Snapshots, Maintenance, and in the future Restore, Estimate,
Verify)

* snapshot: improve counters returned from the upload
2021-02-08 17:54:39 -08:00
Jarek Kowalski
1aad52681a sftp: fixed test (#819) 2021-02-07 06:11:00 -08:00
Jarek Kowalski
75bdefd0b7 dummy commit to trigger new release 2021-02-05 15:14:49 -08:00
Jarek Kowalski
5d07237156 Added support for user authentication using user profiles stored in the repository (#809)
* user: added user profile (username&password for authentication) and CRUD methods
* manifest: helpers for disambiguating manifest entries
* authn: added repository-based user authenticator
* cli: added commands to manipulate user accounts and passwords
* cli: added --allow-repository-users option to 'server start'
* Update cli/command_user_info.go

Co-authored-by: Julio López <julio+gh@kasten.io>
* Always return false when the user is not found.
2021-02-03 22:04:05 -08:00
Jarek Kowalski
7d8a4237ba Upgrade electron 11.2.1 (#817)
* app: update electron to 11.2.1

* app: compat fixes after upgrade
2021-02-03 20:00:40 -08:00
carlbraganza
c23d42f84d Refactored the robustness engine constructor to use externally specified interfaces. (#815) 2021-02-03 11:19:33 -08:00
Jarek Kowalski
1a826d85c5 cli: added '--insecure' flag to 'kopia server start' (#803)
* cli: added '--insecure' flag to 'kopia server start'

This is a breaking change for development scenarios to prevent people
from unknowingly launching insecure servers.

Attempt to start a server without either TLS or password protection
results in an error now (unless --insecure is also passed).

KopiaUI already launches server with TLS and random password, so it
does not require it.
2021-01-28 09:13:57 -08:00
Jarek Kowalski
646c325826 Implemented new streaming GRPC protocol for Kopia Repository Server (#789)
* grpcapi: added GPRC API for the repository server

* repo: added transparent retries to GRPC repository client

Normally GRPC reconnects automatically, which can survive server
restarts (minus transient errors).

In our case we're establishing a stream which will be broken and
needs to be restarted after io.EOF is detected.

It safe to do transparent retries for read-only (repo.Repository),
but not safe for write sessions (repo.RepositoryWriter), because the
session may re-connect to different server that won't have the buffered
content write available in memory.
2021-01-28 05:15:12 -08:00
Jarek Kowalski
a11ddaf2cf restore: added support for incremental restore and ignoring copy errors (#794)
* restore: added support for incremental restore and ignoring copy errors

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-01-27 06:29:15 -08:00
Jarek Kowalski
2a58166c43 lint: upgraded to 1.36 which fixes flakes (#801)
* lint: upgraded to 1.36 which fixes flakes

* ci: removed separate lint action - normal lint is fast enough and less flaky

* ci: also deleted linter_version_test.go
2021-01-26 19:24:30 -08:00
Jarek Kowalski
f9f0f4b079 blob: added tests to ensure providers don't retry on invalid parameters (#802) 2021-01-26 18:13:49 -08:00
Jarek Kowalski
b7e874430f blob: rewrote blob storage providers retry logic (#798)
* blob: rewrote blob storage providers retry logic

Previously we were trying to guess which errors are retriable
(often poorly, since things like DNS or HTTP errors were not retried)

This change makes it so the provider does not need built-in retry logic
and instead retrying wrapper is added which retries on all errors other
than

blob.ErrNotFound, blob.ErrInvalidRange and blob.ErrSetTimeUnsupported.

This required thorough testing of negative conditions that would trigger
blob.ErrInvalidLength (we already had those). Verified that tests pass
against Azure, B2, S3, GCS, Rclone, WebDAV, SFTP.

* lint: fixed spurious failure

* sftp: return proper error on invalid seek

* pr feedback
2021-01-26 05:43:06 -08:00
Jarek Kowalski
ec4bc3c41b Update README.md 2021-01-25 22:20:57 -08:00
Jarek Kowalski
77691cf0a2 sftp: run private SFTP server based on Docker (atmoz/sftp) (#796)
* sftp: run private SFTP server based on Docker (atmoz/sftp)

* sftp: disable test on GH Actions && !linux because it does not support Docker.
2021-01-25 22:13:30 -08:00
carlbraganza
6fd4409bb3 Introduced a FileWriter interface in the robustness test and refactored accordingly. (#797) 2021-01-25 19:57:27 -08:00
Jarek Kowalski
c3e6aebfb6 rclone: provider improvements (#795)
switched local passwd hash to APR1 to support older rclones
install well-known version of rclone for testing
2021-01-25 14:53:55 -08:00
Jarek Kowalski
38fc17bae8 ci: changed cron schedule to run once a week, instead of twice daily 2021-01-24 09:02:15 -08:00
Janne Johansson
45912e272e Option to print out the commands for benchmark (#779)
* Option to print out the commands for using crypto, splitter and compression

Co-authored-by: Janne Johansson <janne.johansson@safespring.com>
Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2021-01-23 20:04:09 -08:00
Jarek Kowalski
6a63c207a4 Upgraded Node and all NPM dependencies to latest versions (#793)
* htmlui: upgraded all NPM dependencies to latest versions

* app: upgraded all NPM dependencies to latest versions

* tools: upgraded node to 14.15.4 LTS

* app: fixed deprecated methods
2021-01-23 18:40:50 -08:00
Julio López
6b245f972c [cleanup] prefer t.Logf over log.Printf in test (#792) 2021-01-21 23:01:12 -08:00
carlbraganza
8d907c937c All robustness test engine interface definitions moved into the test root directory (#791)
* All robustness test engine interface definitions moved into the test root directory.

* Fixed lint issue.
2021-01-21 18:55:08 -08:00
Nick
122a31b905 Overwrite symlinks with optional flag - fix #689 (#783)
Fixes #689

Add symlink overwrite behavior to fix "file exists" error when restoring a symlink that already exists

Before creating the restored symlink, check `os.Lstat`:
- If it returns an error indicating the file does not exist, proceed to symlink creation
- If it returns any other error, propagate the error up to the caller
- If the fileInfo indicates the entry is a symlink AND `--no-overwrite-symlinks` was set in the restore command, propagate an error to the caller
- If `--no-overwrite-symlinks` was NOT set, remove the existing symlink before proceeding to symlink creation
- Else the file exists but it is not of type symlink. Halt the operation and propagate an error indicating we tried to restore a symlink over a file system entry that already existed but was not a symlink.

Added case to `TestSnapshotRestore` that fails before this fix and succeeds after. The case is simply to restore the same snapshot into the same directory twice in a row, where the second restore will be on top of the first one.

Added test case to ensure `--no-overwrite-symlinks` throws an error as expected if restoring into a directory where a symlink already exists at the path symlink creation is attempted.

Added test case to ensure that the restore operation fails if a symlink is needed to be restored to the same path as an existing non-symlink filesystem entry with the same name.

* Skip overwrite test on Windows

If test is run as non-admin it is likely to fail on Windows
with insufficient permissions to overwrite the previously
restored data.

* Add brief summary of overwrite behavior to help

Add a brief summary to the restore command help text
 of expected behavior when restoring into a target location
 that has existing data present.
2021-01-21 12:26:42 -08:00
Jarek Kowalski
25ccbfac48 repo: increased compaction warning threshold 100 -> 1000 (#790) 2021-01-21 11:50:57 -08:00
Jarek Kowalski
5912247f29 server: reworked authn/authz (#788)
* server: reworked authn/authz

Previously authentication was done as an wrapper handler and
authorization was inlined. This change moves authn/authz handlers
inside the server and implements separate authorization module that's
individually tested.

Also fixed an issue where server users were not able to see global
or host-level policies.

* PR feedback
2021-01-21 07:31:34 -08:00
Jarek Kowalski
fa7976599c repo: refactored repository interfaces (#780)
- `repo.Repository` is now read-only and only has methods that can be supported over kopia server
- `repo.RepositoryWriter` has read-write methods that can be supported over kopia server
- `repo.DirectRepository` is read-only and contains all methods of `repo.Repository` plus some low-level methods for data inspection
- `repo.DirectRepositoryWriter` contains write methods for `repo.DirectRepository`

- `repo.Reader` removed and merged with `repo.Repository`
- `repo.Writer` became `repo.RepositoryWriter`
- `*repo.DirectRepository` struct became `repo.DirectRepository`
  interface

Getting `{Direct}RepositoryWriter` requires using `NewWriter()` or `NewDirectWriter()` on a read-only repository and multiple simultaneous writers are supported at the same time, each writing to their own indexes and pack blobs.

`repo.Open` returns `repo.Repository` (which is also `repo.RepositoryWriter`).

* content: removed implicit flush on content manager close
* repo: added tests for WriteSession() and implicit flush behavior
* invalidate manifest manager after write session

* cli: disable maintenance in 'kopia server start'
  Server will close the repository before completing.

* repo: unconditionally close RepositoryWriter in {Direct,}WriteSession
* repo: added panic in case somebody tries to create RepositoryWriter after closing repository
  - used atomic to manage SharedManager.closed

* removed stale example
* linter: fixed spurious failures

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-01-20 11:41:47 -08:00
Jarek Kowalski
04b99c7a28 linter: fixed spurious failures 2021-01-19 22:22:08 -08:00
Jarek Kowalski
1f3b8d4da4 upgrade linter to 1.35 (#786)
* lint: added test that enforces Makefile and GH action linter versions are in sync
* workaround for linter gomnd problem - https://github.com/golangci/golangci-lint/issues/1653
2021-01-16 18:21:16 -08:00
Jarek Kowalski
4c8b9291e1 content: refactoring of Manager (#785)
- renamed content.Manager to content.WriteManager
- merged lockFreeManager and CommittedReadManager into SharedManager
- also reassigned some methods to SharedManager (no code move)
2021-01-14 23:13:57 -08:00
Jarek Kowalski
3cce502017 ci: disabled armhf runner until it's fixed 2021-01-14 20:51:12 -08:00
Jarek Kowalski
f517703079 Preliminary support for sessions (#752)
* content: fixed time-based auto-flush behavior to behave like Flush()

Previously it would sometimes be possible for a content whose write
started before time-based flush to finish writing afterwards (and it
would be included in the new index).

Refactored the code so that time-based flush happens before WriteContent
write and behaves exactly the same was as real Flush() so all writes
started before it will be awaited during the flush.

Also previous regression test was incorrect since it was mocking the
wrong blob method.

* content: refactored index blob manager crypto to separate file

This will be reused for encrypting session info.

* content: added support for session markers

Session marker (`s` blob) is written BEFORE the first data blob
(`p` or `q`) that belongs to new index segment (`n` is written).

Session marker is removed AFTER the index blob (`n`) has been written.

All pack and index blobs belonging to a session will have the session
ID as its suffix, so that if a reader can see `s<sessionID>` blob, they
will ignore any `p` and `q` blobs with the same suffix.

* maintenance: ignore blobs belonging to active sessions when running blob garbage collection

* cli: added 'sessions list' for listing active sessions

*  content: added retrying writing previously failed blobs before writing new one
2021-01-14 00:25:51 -08:00
Jarek Kowalski
ed9db56b87 Cleaned up and refactored object manager (#782)
* object: refactored Open() and VerifyObject() to be stateless

(no code movement yet to facilitate review)

* mechanical: moved function more appropriate files

* object: remove object manager tracing which was unused
2021-01-13 00:40:23 -08:00
Jarek Kowalski
34bf496570 Manifest manager refactoring (#776)
* manifest: refactored management of committed manifests into separate component

This is very similar to content.CommittedReadManager and allows
multiple writes to coexist and share the underlying committed manifest
manager.

Changed compaction to only include previously-committed manifests and
not any pending ones.

Added locking assertions for extra safety.
2021-01-09 07:39:25 -08:00
Jarek Kowalski
dcf2daa050 fixed goreleaser typo 2021-01-08 19:26:24 -08:00