Allow disabling the physical storage cache with 'disable_cache'.

Fixes #674.
This commit is contained in:
Jeff Mitchell 2015-10-12 12:55:02 -04:00
parent 44706da08c
commit 9f0b1547bb
6 changed files with 17 additions and 1 deletions

View File

@ -7,6 +7,7 @@ DEPRECATIONS/BREAKING CHANGES:
IMPROVEMENTS:
* api: API client now uses a 30 second timeout instead of indefinite [GH-681]
* core: The physical storage read cache can now be disabled via "disable_cache" [GH-674]
* core: Tokens can now renew themselves [GH-455]
* core: Base64-encoded PGP keys can be used with the CLI for `init` and `rekey` operations [GH-653]
* logical: Responses now contain a "warnings" key containing a list of warnings returned from the server. These are conditions that did not require failing an operation, but of which the client should be aware. [GH-676]

View File

@ -18,6 +18,7 @@ type Config struct {
Listeners []*Listener `hcl:"-"`
Backend *Backend `hcl:"-"`
DisableCache bool `hcl:"disable_cache"`
DisableMlock bool `hcl:"disable_mlock"`
Telemetry *Telemetry `hcl:"telemetry"`
@ -31,6 +32,7 @@ type Config struct {
// DevConfig is a Config that is used for dev mode of Vault.
func DevConfig() *Config {
return &Config{
DisableCache: false,
DisableMlock: true,
Backend: &Backend{
@ -106,7 +108,12 @@ func (c *Config) Merge(c2 *Config) *Config {
result.Telemetry = c2.Telemetry
}
// merging this boolean via an OR operation
// merging these booleans via an OR operation
result.DisableCache = c.DisableCache
if c2.DisableCache {
result.DisableCache = c2.DisableCache
}
result.DisableMlock = c.DisableMlock
if c2.DisableMlock {
result.DisableMlock = c2.DisableMlock

View File

@ -36,6 +36,7 @@ func TestLoadConfigFile(t *testing.T) {
DisableHostname: false,
},
DisableCache: true,
DisableMlock: true,
MaxLeaseTTL: 10 * time.Hour,
@ -128,6 +129,7 @@ func TestLoadConfigDir(t *testing.T) {
}
expected := &Config{
DisableCache: true,
DisableMlock: true,
Listeners: []*Listener{

View File

@ -1,3 +1,4 @@
disable_cache = true
disable_mlock = true
backend "consul" {

View File

@ -1,3 +1,4 @@
disable_cache = true
disable_mlock = true
statsd_addr = "bar"
statsite_addr = "foo"

View File

@ -42,6 +42,10 @@ to specify where the configuration is.
"tcp" is currently the only option available. A full reference for the
inner syntax is below.
* `disable_cache` (optional) - A boolean. If true, this will disable the
read cache used by the physical storage subsystem. This will very
significantly impact performance.
* `disable_mlock` (optional) - A boolean. If true, this will disable the
server from executing the `mlock` syscall to prevent memory from being
swapped to disk. This is not recommended in production (see below).