Skip to content

Commit

Permalink
fix: change the default prune and check times to be different to prev…
Browse files Browse the repository at this point in the history
…ent clashes
  • Loading branch information
shreddedbacon committed Nov 27, 2023
1 parent 6bd767a commit b23a9ed
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions internal/generator/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

const (
defaultCheckSchedule = "M H(3-6) * * 0"
defaultPruneSchedule = "M H(3-6) * * 0"
defaultCheckSchedule = "M H(5-8) * * 1"
defaultPruneSchedule = "M H(3-5) * * 0"
defaultBackupSchedule = "M H(22-2) * * *"
hourlyDefaultBackupRetention = 0
dailyDefaultBackupRetention = 7
Expand Down Expand Up @@ -104,7 +104,7 @@ func generateBackupValues(
if flagCheckSchedule == "enabled" {
buildValues.Backup.CheckSchedule = "@weekly-random"
} else {
buildValues.Backup.CheckSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, defaultCheckSchedule)
buildValues.Backup.CheckSchedule, err = helpers.ConvertCrontab(fmt.Sprintf("%s", buildValues.Namespace), defaultCheckSchedule)
if err != nil {
return fmt.Errorf("Unable to convert crontab for default check schedule: %v", err)
}
Expand All @@ -113,7 +113,7 @@ func generateBackupValues(
if flagPruneSchedule == "enabled" {
buildValues.Backup.PruneSchedule = "@weekly-random"
} else {
buildValues.Backup.PruneSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, defaultPruneSchedule)
buildValues.Backup.PruneSchedule, err = helpers.ConvertCrontab(fmt.Sprintf("%s", buildValues.Namespace), defaultPruneSchedule)
if err != nil {
return fmt.Errorf("Unable to convert crontab for default prune schedule: %v", err)
}
Expand Down
32 changes: 16 additions & 16 deletions internal/generator/backups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -77,7 +77,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 23 * * 0-5",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -113,7 +113,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 23 * * 0-5",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -147,7 +147,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 23 * * 0-5",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -183,7 +183,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 23 * * 0-5",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -217,7 +217,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 23 * * 0-5",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -253,7 +253,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 23 * * 0-5",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -296,7 +296,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "1,16,31,46 0-23 1-31 1-12 0-6",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -336,7 +336,7 @@ func Test_generateBackupValues(t *testing.T) {
BackupLocationSecretKey: "a1b2c3d4e5f6g7h8i9",
},
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
PruneRetention: PruneRetention{
Hourly: 0,
Expand Down Expand Up @@ -378,7 +378,7 @@ func Test_generateBackupValues(t *testing.T) {
BackupLocationSecretKey: "a1b2c3d4e5f6g7h8i9",
},
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
PruneRetention: PruneRetention{
Hourly: 0,
Expand Down Expand Up @@ -415,7 +415,7 @@ func Test_generateBackupValues(t *testing.T) {
RestoreLocationSecretKey: "a1b2c3d4e5f6g7h8i9",
},
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -462,7 +462,7 @@ func Test_generateBackupValues(t *testing.T) {
RestoreLocationSecretKey: "a1b2c3d4e5f6g7h8i9",
},
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
PruneRetention: PruneRetention{
Hourly: 0,
Expand Down Expand Up @@ -529,7 +529,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-example-project",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -566,7 +566,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "mybucket",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -608,7 +608,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "mybucket",
PruneRetention: PruneRetention{
Expand Down Expand Up @@ -645,7 +645,7 @@ func Test_generateBackupValues(t *testing.T) {
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
CheckSchedule: "31 6 * * 1",
PruneSchedule: "31 4 * * 0",
S3BucketName: "baas-cluster-bucket/baas-example-project",
PruneRetention: PruneRetention{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ spec:
schedule: 5 23 * * *
check:
resources: {}
schedule: 5 5 * * 0
schedule: 5 7 * * 1
prune:
resources: {}
retention:
keepDaily: 7
keepMonthly: 1
keepWeekly: 6
schedule: 5 5 * * 0
schedule: 5 2 * * 0
resourceRequirementsTemplate: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ spec:
schedule: 1,31 23 * * *
check:
resources: {}
schedule: 5 5 * * 0
schedule: 5 7 * * 1
prune:
resources: {}
retention:
keepDaily: 7
keepMonthly: 1
keepWeekly: 6
schedule: 5 5 * * 0
schedule: 5 2 * * 0
resourceRequirementsTemplate: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ spec:
schedule: 5 23 * * *
check:
resources: {}
schedule: 5 5 * * 0
schedule: 5 7 * * 1
prune:
resources: {}
retention:
keepDaily: 10
keepHourly: 10
keepMonthly: 10
keepWeekly: 10
schedule: 5 5 * * 0
schedule: 5 2 * * 0
resourceRequirementsTemplate: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ spec:
schedule: 3,33 12 * * *
check:
resources: {}
schedule: 5 5 * * 0
schedule: 5 7 * * 1
prune:
resources: {}
retention:
keepDaily: 7
keepMonthly: 1
keepWeekly: 6
schedule: 5 5 * * 0
schedule: 5 2 * * 0
resourceRequirementsTemplate: {}
status: {}
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ spec:
schedule: 3,33 12 * * *
check:
resources: {}
schedule: 5 5 * * 0
schedule: 5 7 * * 1
prune:
resources: {}
retention:
keepDaily: 7
keepMonthly: 1
keepWeekly: 6
schedule: 5 5 * * 0
schedule: 5 2 * * 0
resourceRequirementsTemplate: {}
status: {}
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ spec:
schedule: 5,20,35,50 5 * * 0
check:
resources: {}
schedule: 5 5 * * 0
schedule: 5 7 * * 1
prune:
resources: {}
retention:
keepDaily: 10
keepHourly: 10
keepMonthly: 12
keepWeekly: 16
schedule: 5 5 * * 0
schedule: 5 2 * * 0
resourceRequirementsTemplate: {}
status: {}

0 comments on commit b23a9ed

Please sign in to comment.