Skip to content

Commit 6dac978

Browse files
committed
using modify reconciler
1 parent 16a55ad commit 6dac978

5 files changed

Lines changed: 38 additions & 21 deletions

File tree

api/v1beta2/foundationdbcluster_types_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,15 @@ var _ = Describe("[api] FoundationDBCluster", func() {
831831
status := FoundationDBLiveBackupStatus{}
832832
err = statusDecoder.Decode(&status)
833833
Expect(err).NotTo(HaveOccurred())
834+
UID := "3874300eea1e154e4079530b381f71c3"
834835
Expect(status).To(Equal(FoundationDBLiveBackupStatus{
835836
DestinationURL: "blobstore://minio@minio-service:9000/sample-cluster?bucket=fdb-backups",
836837
SnapshotIntervalSeconds: 864000,
837838
Status: FoundationDBLiveBackupStatusState{
838839
Running: true,
839840
},
840841
Restorable: ptr.To(false),
842+
UID: &UID,
841843
}))
842844
})
843845
})

controllers/modify_backup.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ func (s modifyBackup) reconcile(
4545
return nil
4646
}
4747

48-
// Modifying backups will remove encryption from previously encrypted backups.
49-
// To preserve encryption, skip backup modifications if encryption is enabled.
50-
// See FoundationDB issue: https://github.com/apple/foundationdb/issues/12544
51-
if backup.Spec.EncryptionKeyPath != "" {
52-
return nil
53-
}
54-
5548
// The modify command is only required for continuous backups.
5649
if backup.NeedsBackupReconfiguration() &&
5750
backup.GetBackupMode() == fdbv1beta2.BackupModeContinuous {

e2e/fixtures/fdb_backup.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,20 @@ func (fdbBackup *FdbBackup) Pause() {
273273
fdbBackup.setState(fdbv1beta2.BackupStatePaused)
274274
}
275275

276+
// SetSnapshotInterval updates the snapshot interval of the current backup
277+
func (fdbBackup *FdbBackup) SetSnapshotInterval(snapshotPeriodSeconds int) {
278+
objectKey := client.ObjectKeyFromObject(fdbBackup.backup)
279+
foundationDBBackup := &fdbv1beta2.FoundationDBBackup{}
280+
gomega.Expect(fdbBackup.fdbCluster.factory.GetControllerRuntimeClient().
281+
Get(context.Background(), objectKey, foundationDBBackup)).NotTo(gomega.HaveOccurred())
282+
283+
foundationDBBackup.Spec.SnapshotPeriodSeconds = &snapshotPeriodSeconds
284+
gomega.Expect(fdbBackup.fdbCluster.factory.GetControllerRuntimeClient().
285+
Update(context.Background(), foundationDBBackup)).NotTo(gomega.HaveOccurred())
286+
fdbBackup.backup = foundationDBBackup
287+
fdbBackup.WaitForReconciliation()
288+
}
289+
276290
// RunCommandOnBackupPod runs command on the backup pod.
277291
func (fdbBackup *FdbBackup) RunCommandOnBackupPod(command string) string {
278292
backupPod := fdbBackup.GetBackupPod()
@@ -304,12 +318,6 @@ func (fdbBackup *FdbBackup) RunStatusCommand() *fdbv1beta2.FoundationDBLiveBacku
304318
return status
305319
}
306320

307-
// RunModifyCommand runs the modify command on a backup pod to change the snapshot period.
308-
func (fdbBackup *FdbBackup) RunModifyCommand(snapshotPeriodSeconds int, tag string) {
309-
command := fmt.Sprintf("fdbbackup modify -s %d -t %s", snapshotPeriodSeconds, tag)
310-
fdbBackup.RunCommandOnBackupPod(command)
311-
}
312-
313321
// RunListCommand runs the list command on a backup pod.
314322
func (fdbBackup *FdbBackup) RunListCommand() []string {
315323
backupURL, err := fdbBackup.backup.BaseURL()

e2e/test_operator_backups/operator_backup_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
224224
// running status command
225225
statusCommandOutput := backup.RunStatusCommand()
226226
Expect(statusCommandOutput.SnapshotIntervalSeconds).To(Equal(864000))
227+
Expect(statusCommandOutput.UID).NotTo(BeNil())
227228
backupUID := *statusCommandOutput.UID
228229

229230
// running list command
@@ -234,7 +235,7 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
234235
// restart the backup before modifying since the backup is paused
235236
modifiedSnapshotPeriod := 900000
236237
backup.Start()
237-
backup.RunModifyCommand(modifiedSnapshotPeriod, "default")
238+
backup.SetSnapshotInterval(modifiedSnapshotPeriod)
238239
// validating snapshot interval changed and the backup UID is same
239240
statusCommandOutput = backup.RunStatusCommand()
240241
Expect(

fdbclient/admin_client.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,28 @@ func (client *cliAdminClient) ModifyBackup(backup *fdbv1beta2.FoundationDBBackup
941941
return err
942942
}
943943

944+
args := []string{
945+
"modify",
946+
"-s",
947+
strconv.Itoa(backup.SnapshotPeriodSeconds()),
948+
"-d",
949+
backupURL,
950+
}
951+
952+
encryptionKeyPath, err := backup.GetEncryptionKey()
953+
if err != nil {
954+
return err
955+
}
956+
957+
if encryptionKeyPath != "" {
958+
args = append(args, "--encryption-key-file", encryptionKeyPath)
959+
}
960+
961+
client.log.V(1).Info("running backup modify", "command", args)
962+
944963
_, err = client.runCommand(cliCommand{
945964
binary: fdbbackupStr,
946-
args: []string{
947-
"modify",
948-
"-s",
949-
strconv.Itoa(backup.SnapshotPeriodSeconds()),
950-
"-d",
951-
backupURL,
952-
},
965+
args: args,
953966
})
954967

955968
return err

0 commit comments

Comments
 (0)