csi: add option to configure CSIVolumeClaimGCInterval (#16195)

This commit is contained in:
visweshs123 2023-02-16 10:41:15 -05:00 committed by GitHub
parent eaf0be1aba
commit fbc51dd190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 0 deletions

3
.changelog/16195.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
csi: Added server configuration for `csi_volume_claim_gc_interval`
```

View File

@ -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 {

View File

@ -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
}

View File

@ -105,6 +105,7 @@ var basicConfig = &Config{
JobGCInterval: "3m",
JobGCThreshold: "12h",
DeploymentGCThreshold: "12h",
CSIVolumeClaimGCInterval: "3m",
CSIVolumeClaimGCThreshold: "12h",
CSIPluginGCThreshold: "12h",
ACLTokenGCThreshold: "12h",

View File

@ -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"

View File

@ -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",

View File

@ -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".