Commit Graph

421 Commits

Author SHA1 Message Date
Brian Kassouf
9e2111e78d Wrap storage calls with encoding checks (#5819)
* Add encoding backend

* More work on encoding checks

* Update error message

* Update physical/encoding.go

* Disable key checks if configured
2018-11-19 13:13:16 -08:00
Konstantinos Tsanaktsidis
7bf3c14260 Paper over GCS backend corruption issues (#5804)
We're having issues with leases in the GCS backend storage being
corrupted and failing MAC checking. When that happens, we need to know
the lease ID so we can address the corruption by hand and take
appropriate action.

This will hopefully prevent any instances of incomplete data being sent
to GSS
2018-11-16 08:07:06 -05:00
Calvin Leung Huang
6d6fbf2f57 Clean up HABackend tests (#5617) 2018-11-01 10:31:09 -07:00
Calvin Leung Huang
3d1f0d76c0 [Review Only] Autoseal OSS port (#757)
* Port awskms autoseal

* Rename files

* WIP autoseal

* Fix protobuf conflict

* Expose some structs to properly allow encrypting stored keys

* Update awskms with the latest changes

* Add KeyGuard implementation to abstract encryption/decryption of keys

* Fully decouple seal.Access implementations from sealwrap structs

* Add extra line to proto files, comment update

* Update seal_access_entry.go

* govendor sync

* Add endpoint info to configureAWSKMSSeal

* Update comment

* Refactor structs

* Update make proto

* Remove remove KeyGuard, move encrypt/decrypt to autoSeal

* Add rest of seals, update VerifyRecoveryKeys, add deps

* Fix some merge conflicts via govendor updates

* Rename SealWrapEntry to EncryptedBlobInfo

* Remove barrier type upgrade check in oss

* Add key to EncryptedBlobInfo proto

* Update barrierTypeUpgradeCheck signature
2018-10-19 14:43:57 -07:00
dle-fr
e8d435340d [5529] Mysql HA: table creation error using InnoDB and utf8 charset (#5543) 2018-10-18 13:35:04 -04:00
Brian Kassouf
fc1f0af643 Port some changes (#5518) 2018-10-15 14:06:45 -07:00
Calvin Leung Huang
0b2350bc15 Logger cleanup (#5480) 2018-10-09 09:43:17 -07:00
Brian Kassouf
b6ca59f0b4 Fix build (#5457) 2018-10-03 14:53:08 -07:00
Jeff Mitchell
6d79e86cf1 Fix compile on 32-bit platforms 2018-10-02 14:42:50 -04:00
Saurabh Pal
239f2013b8 Enable TLS based communication with Zookeeper Backend (#4856)
* The added method customTLSDial() creates a tls connection to the zookeeper backend when 'tls_enabled' is set to true in config

* Update to the document for TLS configuration that is  required to enable TLS connection to Zookeeper backend

* Minor formatting update

* Minor update to the description for example config

* As per review comments from @kenbreeman, additional property description indicating support for multiple Root CAs in a single file has been added

* minor formatting
2018-10-01 14:12:08 -07:00
Becca Petrin
11abcec826 point at a fork of aliyun-oss-go-sdk (#5358) 2018-10-01 10:05:08 -07:00
Jeff Mitchell
e7c4158e60 Fix compilation/protobuf 2018-09-22 17:58:39 -04:00
pavel-usov
e020e7eea6 Change in GET_LOCK call to make it MariaDB compatilble (#5343)
* Update mysql.go

Change in GET_LOCK call to make it MariaDB compatilble

* Use math.MaxUint32 for lock timeout, add comments
2018-09-19 12:05:04 -07:00
Jeff Mitchell
b7d6d55ac1 The big one (#5346) 2018-09-17 23:03:00 -04:00
Jeff Mitchell
7d564c5ec4 Add an option to log all ops to inmem (#5306) 2018-09-07 17:35:46 -04:00
Jeff Mitchell
3011228478 Cache negative results in physical cache (#5303) 2018-09-07 14:56:33 -04:00
Jeff Mitchell
ab5966d44a Move things back 2018-08-29 19:13:10 -04:00
Jeff Mitchell
4f561bc0c9 Move physical types around 2018-08-29 19:05:33 -04:00
Jeff Mitchell
b80170787b Move sort from listresponse to file backend to solve 5141 2018-08-24 13:37:15 -04:00
Oleksiy Kovyrin
dd1ceaca7a A simple copy-paste fix (#5130)
The test for MySQL HA backend seems to have been based on the Zookeeper one and the error message in it did not get updated to be MySQL-specific.
2018-08-17 08:46:56 -04:00
brianvans
801eddf5f8 Add ha_enabled for mysql backend (#5122)
* Slight cleanup around mysql ha lock implementation

* Removes some duplication around lock table naming
* Escapes lock table name with backticks to handle weird characters
* Lock table defaults to regular table name + "_lock"
* Drop lock table after tests run

* Add `ha_enabled` option for mysql storage

It defaults to false, and we gate a few things like creating the lock
table and preparing lock related statements on it
2018-08-16 11:03:16 -07:00
Christoph Ludwig
d74fae41ef Add support for "sovereign" Azure cloud environments (#4997)
* Add support for "sovereign" Azure cloud environments

* Shorten variable names
2018-08-15 19:40:36 -04:00
Seth Vargo
19f1a94a69 Fix Google Cloud races (#5081)
* storage/gcs: fix race condition in releasing lock

Previously we were deleting a lock without first checking if the lock we were deleting was our own. There existed a small period of time where vault-0 would lose leadership and vault-1 would get leadership. vault-0 would delete the lock key while vault-1 would write it. If vault-0 won, there'd be another leader election, etc.

This fixes the race by using a CAS operation instead.

* storage/gcs: properly break out of loop during stop

* storage/spanner: properly break out of loop during stop
2018-08-14 09:53:36 -04:00
Nándor István Krácser
23d89841d7 Alibaba Object Storage support (#4783) 2018-08-13 17:03:24 -04:00
Michael Schuett
88fe0fad24 MySQL HA Backend Support (#4686) 2018-08-13 17:02:31 -04:00
bohr
9cd4c31cf6 add backtick to fix mysql database name contain special characters (#5054)
when use mysql storage, set` database = "dev-dassets-bc"` , create database and create table will throw exceptions as follows:

    Error initializing storage of type mysql: failed to create mysql database: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-dassets-bc' at line 1
    Error initializing storage of type mysql: failed to create mysql table: Error 1046: No database selected

cause of `-` is  a MySQL  built-in symbol. so add backtick for create database sql\create table sql \dml sqls.
2018-08-10 16:38:20 -07:00
Calvin Leung Huang
ece7569aca Clean up container on connection failure, switch to ory/dockertest on package postgresql (#5050) 2018-08-07 09:56:33 -07:00
Jeff Mitchell
b9adaf9c69 Add request timeouts in normal request path and to expirations (#4971)
* Add request timeouts in normal request path and to expirations

* Add ability to adjust default max request duration

* Some test fixes

* Ensure tests have defaults set for max request duration

* Add context cancel checking to inmem/file

* Fix tests

* Fix tests

* Set default max request duration to basically infinity for this release for BC

* Address feedback
2018-07-24 14:50:49 -07:00
Chris Hoffman
fc1fefdaf3 Read all pages when list results are paged (#4983) 2018-07-24 14:24:32 -04:00
Julien Blache
e59d19325c FoundationDB physical backend (#4900) 2018-07-16 10:18:09 -04:00
Richie Yeung
5d26376460 Fix empty string check for password (#4923) 2018-07-13 12:35:06 -07:00
Seth Vargo
1ce2513920 Use context from stdlib in google physical backends (#4922)
* Use context from stdlib in google physical backends

* Do not prefix logs (Vault will do it)
2018-07-13 11:00:38 -04:00
Jeff Mitchell
11c8eb896f Change x/net context package to go stdlib 2018-07-13 10:59:34 -04:00
Jeff Mitchell
f85efad941 Remove unnecessary log scoping in some physical backends 2018-07-13 10:57:30 -04:00
Jeff Mitchell
dba48d5265 Re-add dockertest and fix up imports and update script (#4909) 2018-07-11 17:49:13 -04:00
Md. Nure Alam Nahid
cf587cf525 Add additional config keys for swift (#4901)
* Add additional config keys for swift

* Add additional swift config keys in the doc page
2018-07-11 08:29:29 -07:00
Jeff Mitchell
ff8becca15 Make proto
It appears the only thing that actually change is that the tag got
`proto3` values added.
2018-07-10 20:49:48 -04:00
Jeff Mitchell
f493d2436e Add an idle timeout for the server (#4760)
* Add an idle timeout for the server

Because tidy operations can be long-running, this also changes all tidy
operations to behave the same operationally (kick off the process, get a
warning back, log errors to server log) and makes them all run in a
goroutine.

This could mean a sort of hard stop if Vault gets sealed because the
function won't have the read lock. This should generally be okay
(running tidy again should pick back up where it left off), but future
work could use cleanup funcs to trigger the functions to stop.

* Fix up tidy test

* Add deadline to cluster connections and an idle timeout to the cluster server, plus add readheader/read timeout to api server
2018-06-16 18:21:33 -04:00
Jeff Mitchell
80250cb5fc Revert some of commit 050ab805a7. (#4768)
If we have a panic defer functions are run but unlocks aren't. Since we
can't really trust plugins and storage, this backs out the changes for
those parts of the request path.
2018-06-14 13:44:13 -04:00
Jeff Mitchell
050ab805a7 Remove a lot of deferred functions in the request path. (#4733)
* Remove a lot of deferred functions in the request path.

There is an interesting benchmark at https://www.reddit.com/r/golang/comments/3h21nk/simple_micro_benchmark_to_measure_the_overhead_of/

It shows that defer actually adds quite a lot of overhead -- maybe 100ns
per call but we defer a *lot* of functions in the request path. So this
removes some of the ones in request handling, ha, barrier, router, and
physical cache.

One meta-note: nearly every metrics function is in a defer which means
every metrics call we add could add a non-trivial amount of time, e.g.
for every 10 extra metrics statements we add 1ms to a request. I don't
know how to solve this right now without doing what I did in some of
these cases and putting that call into a simple function call that then
goes before each return.

* Simplify barrier defer cleanup
2018-06-14 09:49:10 -04:00
Jim Kalafut
1b5b20435b Add DynamoDB marshaling update test (#4746)
This test fails before the d3604289be update.
2018-06-12 08:22:02 -07:00
Jeff Mitchell
c70703985b Add context handling to Consul operations (#4739) 2018-06-11 11:03:00 -04:00
Jeff Mitchell
5086e9cf76 Fix another test error 2018-06-09 18:31:47 -04:00
Jeff Mitchell
822ff4a98d Fix nil pointer in transactional_inmem 2018-06-09 18:22:45 -04:00
Jeff Mitchell
e1a89e0d55 Some atomic cleanup (#4732)
Taking inspiration from
https://github.com/golang/go/issues/17604#issuecomment-256384471
suggests that taking the address of a stack variable for use in atomics
works (at least, the race detector doesn't complain) but is doing it
wrong.

The only other change is a change in Leader() detecting if HA is enabled
to fast-path out. This value never changes after NewCore, so we don't
need to grab the read lock to check it.
2018-06-09 15:35:22 -04:00
Jeff Mitchell
2de2a30232 Fix swallowed err from gcs close calls (#4706) 2018-06-05 15:27:02 -04:00
Jeff Mitchell
58ac805f2e Do some best-effort cleanup in file backend (#4684)
* Do some best-effort cleanup in file backend

If put results in an encoding error and after the file is closed we
detect it's zero bytes, it could be caused by an out of space error on
the disk since file info is often stored in filesystem metadata with
reserved space. This tries to detect that scenario and perform
best-effort cleanup. We only do this on zero length files to ensure that
if an encode fails to write but the system hasn't already performed
truncation, we leave the existing data alone.

Vault should never write a zero-byte file (as opposed to a zero-byte
value in the encoded JSON) so if this case is hit it's always an error.

* Also run a check on Get
2018-06-04 19:41:36 -04:00
Chris Hoffman
3b1ade706c adding option go_package to protos (#4687)
* adding option go_package to protos

* switching proto output dir to relative paths
2018-06-04 10:19:26 -04:00
Jeff Mitchell
8011cfe703 Update to TrustedCAFile for etcd as CAFile is deprecated and removed in latest libs 2018-05-22 15:46:39 -04:00
Martin Hrabovcin
358aabab95 physical/zookeeper: Re-try to release lock in case of failure (#4569) 2018-05-17 15:52:50 -07:00