Skip to content

Commit ef0e977

Browse files
author
Milla Samuel
committed
Modify
1 parent b88d199 commit ef0e977

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

api/v1beta2/foundationdbbackup_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ func (backup *FoundationDBBackup) CheckReconciliation() (bool, error) {
298298
reconciled = false
299299
}
300300

301+
desiredBackupURL := backup.BackupURL()
302+
if backup.Status.BackupDetails.URL != desiredBackupURL {
303+
backup.Status.Generations.NeedsBackupReconfiguration = backup.Generation
304+
reconciled = false
305+
}
306+
301307
isRunning := backup.Status.BackupDetails != nil && backup.Status.BackupDetails.Running
302308
isPaused := backup.Status.BackupDetails != nil && backup.Status.BackupDetails.Paused
303309

controllers/admin_client_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ var _ = Describe("admin_client_test", func() {
325325

326326
Context("with a modification to the snapshot time", func() {
327327
BeforeEach(func() {
328-
err = mockAdminClient.ModifyBackup(20)
328+
err = mockAdminClient.ModifyBackup(
329+
20,
330+
"blobstore://test@test-service/test-backup",
331+
)
329332
Expect(err).NotTo(HaveOccurred())
330333
})
331334

controllers/modify_backup.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ func (s modifyBackup) reconcile(
4242
}
4343

4444
snapshotPeriod := backup.SnapshotPeriodSeconds()
45-
if backup.Status.BackupDetails.SnapshotPeriodSeconds != snapshotPeriod {
45+
backupURL := backup.BackupURL()
46+
47+
shouldModify := backup.Status.BackupDetails.SnapshotPeriodSeconds != snapshotPeriod ||
48+
backup.Status.BackupDetails.URL != backupURL
49+
if shouldModify {
4650
adminClient, err := r.adminClientForBackup(ctx, backup)
4751
if err != nil {
4852
return &requeue{curError: err}
@@ -51,7 +55,7 @@ func (s modifyBackup) reconcile(
5155
_ = adminClient.Close()
5256
}()
5357

54-
err = adminClient.ModifyBackup(snapshotPeriod)
58+
err = adminClient.ModifyBackup(snapshotPeriod, backupURL)
5559
if err != nil {
5660
return &requeue{curError: err}
5761
}

fdbclient/admin_client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,13 +873,15 @@ func (client *cliAdminClient) ResumeBackups() error {
873873
}
874874

875875
// ModifyBackup updates the backup parameters.
876-
func (client *cliAdminClient) ModifyBackup(snapshotPeriodSeconds int) error {
876+
func (client *cliAdminClient) ModifyBackup(snapshotPeriodSeconds int, url string) error {
877877
_, err := client.runCommand(cliCommand{
878878
binary: fdbbackupStr,
879879
args: []string{
880880
"modify",
881881
"-s",
882882
fmt.Sprintf("%d", snapshotPeriodSeconds),
883+
"-d",
884+
url,
883885
},
884886
})
885887
return err

kubectl-fdb/cmd/version_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1717
* See the License for the specific language governing permissions and
1818
* limitations under the License.
19-
*/
20-
package cmd
19+
*/package cmd
2120

2221
import (
2322
"bytes"

pkg/fdbadminclient/admin_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type AdminClient interface {
8282
ResumeBackups() error
8383

8484
// ModifyBackup modifies the configuration of the backup.
85-
ModifyBackup(int) error
85+
ModifyBackup(snapshotPeriodSeconds int, url string) error
8686

8787
// GetBackupStatus gets the status of the current backup.
8888
GetBackupStatus() (*fdbv1beta2.FoundationDBLiveBackupStatus, error)

pkg/fdbadminclient/mock/admin_client_mock.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ func (client *AdminClient) ResumeBackups() error {
909909
}
910910

911911
// ModifyBackup reconfigures the backup.
912-
func (client *AdminClient) ModifyBackup(snapshotPeriodSeconds int) error {
912+
func (client *AdminClient) ModifyBackup(snapshotPeriodSeconds int, url string) error {
913913
adminClientMutex.Lock()
914914
defer adminClientMutex.Unlock()
915915

@@ -919,6 +919,7 @@ func (client *AdminClient) ModifyBackup(snapshotPeriodSeconds int) error {
919919

920920
backup := client.Backups["default"]
921921
backup.SnapshotPeriodSeconds = snapshotPeriodSeconds
922+
backup.URL = url
922923
client.Backups["default"] = backup
923924
return nil
924925
}

0 commit comments

Comments
 (0)