mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
csi: add option to configure CSIVolumeClaimGCInterval (#16195)
This commit is contained in:
3
.changelog/16195.txt
Normal file
3
.changelog/16195.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:improvement
|
||||
csi: Added server configuration for `csi_volume_claim_gc_interval`
|
||||
```
|
||||
@@ -404,6 +404,15 @@ func convertServerConfig(agentConfig *Config) (*nomad.Config, error) {
|
||||
}
|
||||
conf.DeploymentGCThreshold = dur
|
||||
}
|
||||
if gcInterval := agentConfig.Server.CSIVolumeClaimGCInterval; gcInterval != "" {
|
||||
dur, err := time.ParseDuration(gcInterval)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if dur <= time.Duration(0) {
|
||||
return nil, fmt.Errorf("csi_volume_claim_gc_interval should be greater than 0s")
|
||||
}
|
||||
conf.CSIVolumeClaimGCInterval = dur
|
||||
}
|
||||
if gcThreshold := agentConfig.Server.CSIVolumeClaimGCThreshold; gcThreshold != "" {
|
||||
dur, err := time.ParseDuration(gcThreshold)
|
||||
if err != nil {
|
||||
|
||||
@@ -490,6 +490,10 @@ type ServerConfig struct {
|
||||
// GCed but the threshold can be used to filter by age.
|
||||
DeploymentGCThreshold string `hcl:"deployment_gc_threshold"`
|
||||
|
||||
// CSIVolumeClaimGCInterval is how often we dispatch a job to GC
|
||||
// volume claims.
|
||||
CSIVolumeClaimGCInterval string `hcl:"csi_volume_claim_gc_interval"`
|
||||
|
||||
// CSIVolumeClaimGCThreshold controls how "old" a CSI volume must be to
|
||||
// have its claims collected by GC. Age is not the only requirement for
|
||||
// a volume to be GCed but the threshold can be used to filter by age.
|
||||
@@ -1876,6 +1880,9 @@ func (s *ServerConfig) Merge(b *ServerConfig) *ServerConfig {
|
||||
if b.DeploymentGCThreshold != "" {
|
||||
result.DeploymentGCThreshold = b.DeploymentGCThreshold
|
||||
}
|
||||
if b.CSIVolumeClaimGCInterval != "" {
|
||||
result.CSIVolumeClaimGCInterval = b.CSIVolumeClaimGCInterval
|
||||
}
|
||||
if b.CSIVolumeClaimGCThreshold != "" {
|
||||
result.CSIVolumeClaimGCThreshold = b.CSIVolumeClaimGCThreshold
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ var basicConfig = &Config{
|
||||
JobGCInterval: "3m",
|
||||
JobGCThreshold: "12h",
|
||||
DeploymentGCThreshold: "12h",
|
||||
CSIVolumeClaimGCInterval: "3m",
|
||||
CSIVolumeClaimGCThreshold: "12h",
|
||||
CSIPluginGCThreshold: "12h",
|
||||
ACLTokenGCThreshold: "12h",
|
||||
|
||||
1
command/agent/testdata/basic.hcl
vendored
1
command/agent/testdata/basic.hcl
vendored
@@ -114,6 +114,7 @@ server {
|
||||
job_gc_threshold = "12h"
|
||||
eval_gc_threshold = "12h"
|
||||
deployment_gc_threshold = "12h"
|
||||
csi_volume_claim_gc_interval = "3m"
|
||||
csi_volume_claim_gc_threshold = "12h"
|
||||
csi_plugin_gc_threshold = "12h"
|
||||
acl_token_gc_threshold = "12h"
|
||||
|
||||
1
command/agent/testdata/basic.json
vendored
1
command/agent/testdata/basic.json
vendored
@@ -273,6 +273,7 @@
|
||||
],
|
||||
"encrypt": "abc",
|
||||
"eval_gc_threshold": "12h",
|
||||
"csi_volume_claim_gc_interval": "3m",
|
||||
"heartbeat_grace": "30s",
|
||||
"job_gc_interval": "3m",
|
||||
"job_gc_threshold": "12h",
|
||||
|
||||
@@ -107,6 +107,9 @@ server {
|
||||
deployment must be in the terminal state before it is eligible for garbage
|
||||
collection. This is specified using a label suffix like "30s" or "1h".
|
||||
|
||||
- `csi_volume_claim_gc_interval` `(string: "5m")` - Specifies the interval
|
||||
between CSI volume claim garbage collections.
|
||||
|
||||
- `csi_volume_claim_gc_threshold` `(string: "1h")` - Specifies the minimum age of
|
||||
a CSI volume before it is eligible to have its claims garbage collected.
|
||||
This is specified using a label suffix like "30s" or "1h".
|
||||
|
||||
Reference in New Issue
Block a user