Skip to content

Commit db9e767

Browse files
authored
Fix passing incompatible parameters to fdbbackup and fdbrestore via CustomParameters (#2348)
CustomParameters in FoundationDBBackup and FoundationdbRestore CRDs are meant to be passed to backup agents. However, they are also passed to fdbbackup and fdbrestore commands when admincli object is built. An incompatible backup_agent parameter will be rejected by fdbbackup/restore, causing the fdbbackup to never reconcile. We filter out the parameters that are exclusive to backup_agents.
1 parent 9d93f3b commit db9e767

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

api/v1beta2/foundationdb_custom_parameter.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ func (customParameters FoundationDBCustomParameters) GetKnobsForCLI() []string {
4545
return args
4646
}
4747

48+
// GetKnobsForBackupRestoreCLI returns the list of knobs that should be provided to the fdbbackup and fdbrestore
49+
// when running them over the admin client. It filters out the incompatible ones.
50+
func (customParameters FoundationDBCustomParameters) GetKnobsForBackupRestoreCLI() []string {
51+
args := make([]string, 0, len(customParameters))
52+
53+
for _, arg := range customParameters {
54+
parameterName := strings.Split(string(arg), "=")[0]
55+
parameterName = strings.TrimSpace(parameterName)
56+
if _, ok := backupAgentExclusiveParameters[parameterName]; ok {
57+
continue
58+
}
59+
args = append(args, fmt.Sprintf("--%s", arg))
60+
}
61+
return args
62+
}
63+
4864
var (
4965
protectedParameters = map[string]None{
5066
"datadir": {},
@@ -62,6 +78,11 @@ var (
6278
"user": {},
6379
"group": {},
6480
}
81+
// these parameters are supported by backup_agents but not by fdbbackup and fdbrestore.
82+
backupAgentExclusiveParameters = map[string]None{
83+
"locality-data_hall": {},
84+
"locality_data_center": {},
85+
}
6586
)
6687

6788
// ValidateCustomParameters ensures that no duplicate values are set and that no

api/v1beta2/foundationdb_custom_parameter_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ var _ = Describe("FoundationDBCustomParameters", func() {
4747
})
4848
})
4949

50+
When("getting the custom parameters for the fdbbackup and fdbrestore CLI", func() {
51+
var customParameters FoundationDBCustomParameters
52+
BeforeEach(func() {
53+
customParameters = []FoundationDBCustomParameter{
54+
"knob_http_verbose_level=3",
55+
"locality-data_hall=az1",
56+
}
57+
})
58+
59+
It("", func() {
60+
expected := []string{
61+
"--knob_http_verbose_level=3",
62+
}
63+
64+
result := customParameters.GetKnobsForBackupRestoreCLI()
65+
Expect(result).To(ContainElements(expected))
66+
Expect(len(result)).To(Equal(len(expected)))
67+
})
68+
})
69+
5070
When("Validating the custom parameters", func() {
5171
DescribeTable("should print the correct string",
5272
func(customParameters FoundationDBCustomParameters, expected error) {

controllers/backup_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (r *FoundationDBBackupReconciler) adminClientForBackup(
140140
return nil, err
141141
}
142142

143-
adminClient.SetKnobs(backup.Spec.CustomParameters.GetKnobsForCLI())
143+
adminClient.SetKnobs(backup.Spec.CustomParameters.GetKnobsForBackupRestoreCLI())
144144

145145
return adminClient, nil
146146
}

controllers/restore_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (r *FoundationDBRestoreReconciler) adminClientForRestore(
141141
return nil, err
142142
}
143143

144-
adminClient.SetKnobs(restore.Spec.CustomParameters.GetKnobsForCLI())
144+
adminClient.SetKnobs(restore.Spec.CustomParameters.GetKnobsForBackupRestoreCLI())
145145

146146
return adminClient, nil
147147
}

0 commit comments

Comments
 (0)