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 Feb 4, 2025
1 parent 3eaa739 commit b4247c9
Show file tree
Hide file tree
Showing 4 changed files with 53 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. backup-repository-configmap adds an option for configurable`fullMaintenanceInterval` where fastGC (12 hours), and eagerGC (6 hours) allowing for faster removal of deleted velero backups from kopia repo.
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
28 changes: 27 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,34 @@ 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 allowing for faster removal of deleted velero backups from kopia repo.
- 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
}
```

Per kopia [Maintenance Safety](https://kopia.io/docs/advanced/maintenance/#maintenance-safety), it is expected that velero backup deletion will not result in immediate kopia repository data removal. Reducing full maintenance interval using above options should help reduce time taken to remove blobs not in use.

### 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 b4247c9

Please sign in to comment.