Skip to content

Commit

Permalink
Allow disabling the physical storage cache with 'disable_cache'.
Browse files Browse the repository at this point in the history
Fixes #674.
  • Loading branch information
jefferai committed Oct 12, 2015
1 parent 9549d9e commit 6769705
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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]
Expand Down
9 changes: 8 additions & 1 deletion command/server/config.go
Expand Up @@ -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"`
Expand All @@ -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{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions command/server/config_test.go
Expand Up @@ -36,6 +36,7 @@ func TestLoadConfigFile(t *testing.T) {
DisableHostname: false,
},

DisableCache: true,
DisableMlock: true,

MaxLeaseTTL: 10 * time.Hour,
Expand Down Expand Up @@ -128,6 +129,7 @@ func TestLoadConfigDir(t *testing.T) {
}

expected := &Config{
DisableCache: true,
DisableMlock: true,

Listeners: []*Listener{
Expand Down
1 change: 1 addition & 0 deletions command/server/test-fixtures/config-dir/foo.hcl
@@ -1,3 +1,4 @@
disable_cache = true
disable_mlock = true

backend "consul" {
Expand Down
1 change: 1 addition & 0 deletions command/server/test-fixtures/config.hcl
@@ -1,3 +1,4 @@
disable_cache = true
disable_mlock = true
statsd_addr = "bar"
statsite_addr = "foo"
Expand Down
4 changes: 4 additions & 0 deletions website/source/docs/config/index.html.md
Expand Up @@ -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).
Expand Down

0 comments on commit 6769705

Please sign in to comment.