Merge pull request #2427 from hashicorp/f-gc-limit

Limit parallelism during garbage collection
This commit is contained in:
Alex Dadgar
2017-03-14 10:45:29 -07:00
committed by GitHub
10 changed files with 298 additions and 229 deletions

View File

@@ -310,6 +310,7 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) {
// Set the GC related configs
conf.GCInterval = a.config.Client.GCInterval
conf.GCParallelDestroys = a.config.Client.GCParallelDestroys
conf.GCDiskUsageThreshold = a.config.Client.GCDiskUsageThreshold
conf.GCInodeUsageThreshold = a.config.Client.GCInodeUsageThreshold
conf.NoHostUUID = a.config.Client.NoHostUUID

View File

@@ -54,6 +54,7 @@ client {
collection_interval = "5s"
}
gc_interval = "6s"
gc_parallel_destroys = 6
gc_disk_usage_threshold = 82
gc_inode_usage_threshold = 91
no_host_uuid = true

View File

@@ -202,6 +202,10 @@ type ClientConfig struct {
// collection
GCInterval time.Duration `mapstructure:"gc_interval"`
// GCParallelDestroys is the number of parallel destroys the garbage
// collector will allow.
GCParallelDestroys int `mapstructure:"gc_parallel_destroys"`
// GCInodeUsageThreshold is the inode usage threshold beyond which the Nomad
// client triggers GC of the terminal allocations
GCDiskUsageThreshold float64 `mapstructure:"gc_disk_usage_threshold"`
@@ -524,6 +528,7 @@ func DefaultConfig() *Config {
ClientMaxPort: 14512,
Reserved: &Resources{},
GCInterval: 1 * time.Minute,
GCParallelDestroys: 2,
GCInodeUsageThreshold: 70,
GCDiskUsageThreshold: 80,
},
@@ -929,6 +934,9 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig {
if b.GCInterval != 0 {
result.GCInterval = b.GCInterval
}
if b.GCParallelDestroys != 0 {
result.GCParallelDestroys = b.GCParallelDestroys
}
if b.GCDiskUsageThreshold != 0 {
result.GCDiskUsageThreshold = b.GCDiskUsageThreshold
}

View File

@@ -344,6 +344,7 @@ func parseClient(result **ClientConfig, list *ast.ObjectList) error {
"gc_interval",
"gc_disk_usage_threshold",
"gc_inode_usage_threshold",
"gc_parallel_destroys",
"no_host_uuid",
}
if err := checkHCLKeys(listVal, valid); err != nil {

View File

@@ -71,6 +71,7 @@ func TestConfig_Parse(t *testing.T) {
ParsedReservedPorts: []int{1, 10, 11, 12, 100},
},
GCInterval: 6 * time.Second,
GCParallelDestroys: 6,
GCDiskUsageThreshold: 82,
GCInodeUsageThreshold: 91,
NoHostUUID: true,

View File

@@ -212,6 +212,7 @@ func TestConfig_Merge(t *testing.T) {
ParsedReservedPorts: []int{1, 2, 3},
},
GCInterval: 6 * time.Second,
GCParallelDestroys: 6,
GCDiskUsageThreshold: 71,
GCInodeUsageThreshold: 86,
},