Skip to content

Commit

Permalink
csi: add option to configure CSIVolumeClaimGCInterval (#16195)
Browse files Browse the repository at this point in the history
  • Loading branch information
visweshs-cb authored Feb 16, 2023
1 parent 26f8a95 commit 7d4ccf1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/16195.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
csi: Added server configuration for `csi_volume_claim_gc_interval`
```
9 changes: 9 additions & 0 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions command/agent/config_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var basicConfig = &Config{
JobGCInterval: "3m",
JobGCThreshold: "12h",
DeploymentGCThreshold: "12h",
CSIVolumeClaimGCInterval: "3m",
CSIVolumeClaimGCThreshold: "12h",
CSIPluginGCThreshold: "12h",
ACLTokenGCThreshold: "12h",
Expand Down
1 change: 1 addition & 0 deletions command/agent/testdata/basic.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions command/agent/testdata/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions website/content/docs/configuration/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down

0 comments on commit 7d4ccf1

Please sign in to comment.