Skip to content

Commit

Permalink
Configurable Kopia Maintenance Interval
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Jan 16, 2025
1 parent 3eaa739 commit 334ac16
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/8581-kaovilai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Configurable Kopia Maintenance Interval. repo-maintenance-job-configmap adds an option for `fullMaintenanceInterval` where fastGC (12 hours), and eagerGC (6 hours).
13 changes: 13 additions & 0 deletions pkg/repository/udmrepo/kopialib/lib_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,19 @@ func writeInitParameters(ctx context.Context, repoOption udmrepo.RepoOptions, lo
logger.Infof("Quick maintenance interval change from %v to %v", p.QuickCycle.Interval, overwriteQuickMaintainInterval)
p.QuickCycle.Interval = overwriteQuickMaintainInterval
}
fullMaintIntervalOption := udmrepo.FullMaintenanceIntervalOptions(repoOption.StorageOptions[udmrepo.StoreOptionKeyFullMaintenanceInterval])
if fullMaintIntervalOption == udmrepo.FastGC {
logger.Infof("Full maintenance interval change from %v to %v", p.FullCycle.Interval, udmrepo.FastGCInterval)
p.FullCycle.Interval = udmrepo.FastGCInterval
}

Check warning on line 607 in pkg/repository/udmrepo/kopialib/lib_repo.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/udmrepo/kopialib/lib_repo.go#L605-L607

Added lines #L605 - L607 were not covered by tests
if fullMaintIntervalOption == udmrepo.EagerGC {
logger.Infof("Full maintenance interval change from %v to %v", p.FullCycle.Interval, udmrepo.EagerGCInterval)
p.FullCycle.Interval = udmrepo.EagerGCInterval
}

Check warning on line 611 in pkg/repository/udmrepo/kopialib/lib_repo.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/udmrepo/kopialib/lib_repo.go#L609-L611

Added lines #L609 - L611 were not covered by tests
if fullMaintIntervalOption == udmrepo.NormalGC {
logger.Infof("Full maintenance interval change from %v to %v", p.FullCycle.Interval, udmrepo.NormalGCInterval)
p.FullCycle.Interval = udmrepo.NormalGCInterval
}

Check warning on line 615 in pkg/repository/udmrepo/kopialib/lib_repo.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/udmrepo/kopialib/lib_repo.go#L613-L615

Added lines #L613 - L615 were not covered by tests

p.Owner = r.ClientOptions().UsernameAtHost()

Expand Down
12 changes: 12 additions & 0 deletions pkg/repository/udmrepo/repo_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"os"
"path/filepath"
"strings"
"time"
)

const (
Expand Down Expand Up @@ -70,8 +71,19 @@ const (
ThrottleOptionListOps = "listOPS"
ThrottleOptionUploadBytes = "uploadBytes"
ThrottleOptionDownloadBytes = "downloadBytes"
// FullMaintenanceInterval will overwrite kopia maintenance interval
// options are fastGC for 12 hours, eagerGC for 6 hours
StoreOptionKeyFullMaintenanceInterval = "fullMaintenanceInterval"
FastGC FullMaintenanceIntervalOptions = "fastGC"
FastGCInterval time.Duration = 12 * time.Hour
EagerGC FullMaintenanceIntervalOptions = "eagerGC"
EagerGCInterval time.Duration = 6 * time.Hour
NormalGC FullMaintenanceIntervalOptions = "normalGC"
NormalGCInterval time.Duration = 24 * time.Hour
)

type FullMaintenanceIntervalOptions string

const (
defaultUsername = "default"
defaultDomain = "default"
Expand Down
26 changes: 25 additions & 1 deletion site/content/docs/main/repository-maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,32 @@ velero install --default-repo-maintain-frequency <DURATION>
```
For Kopia the default maintenance frequency is 1 hour, and Restic is 7 * 24 hours.

### Full Maintenance Interval customization
The full maintenance interval defaults to kopia defaults of 24 hours. Velero provide three override options under `fullMaintenanceInterval` configuration using `backup-repository-configmap` ConfigMap provided to velero install commands.
- normalGC: 24 hours
- fastGC: 12 hours
- eagerGC: 6 hours

Example of the `backup-repository-configmap` ConfigMap for the above scenario is as below:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: <config-name>
namespace: velero
data:
<repository-type-1>: |
{
"fullMaintenanceInterval": fastGC
}
<repository-type-2>: |
{
"fullMaintenanceInterval": normalGC
}
```

### Others
Maintenance jobs will inherit the labels, annotations, toleration, nodeSelector, service account, image, environment variables, cloud-credentials etc. from Velero deployment.

[1]: velero-install.md#usage
[2]: node-agent-concurrency.md
[2]: node-agent-concurrency.md

0 comments on commit 334ac16

Please sign in to comment.