Conversation
| func (spec *PerconaPGClusterSpec) BackupsEnabled() bool { | ||
| return spec.Backups.Enabled == nil || *spec.Backups.Enabled | ||
| } |
There was a problem hiding this comment.
I think we should document here that this works like that because backups were enabled by default before these changes, by looking it with fresh eyes, seems like inconsistency/bug.
I think we can also add a unit test like the following
func TestPerconaPGCluster_BackupsEnabled(t *testing.T) {
trueVal := true
falseVal := false
tests := map[string]struct {
spec PerconaPGClusterSpec
expected bool
}{
"Enabled is nil - should return true <explain reason maybe>": {
spec: PerconaPGClusterSpec{Backups: Backups{Enabled: nil}},
expected: true,
},
"Enabled is true, should return true": {
spec: PerconaPGClusterSpec{Backups: Backups{Enabled: &trueVal}},
expected: true,
},
"Enabled is false - should return false": {
spec: PerconaPGClusterSpec{Backups: Backups{Enabled: &falseVal}},
expected: false,
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
actual := tt.spec.BackupsEnabled()
assert.Equal(t, tt.expected, actual)
})
}
}
| } | ||
|
|
||
| func (spec *PerconaPGClusterSpec) BackupsEnabled() bool { | ||
| return spec.Backups.Enabled == nil || *spec.Backups.Enabled |
There was a problem hiding this comment.
I think that given that we introduce this function, we should first add this function with Backups receiver since it is its own responsibility to determine if it is enabled or not, and then this new function can be used here because PerconaPGClusterSpec knows Backups
There was a problem hiding this comment.
we can then use this new function with the backups receiver, here
func (b Backups) ToCrunchy(version string) crunchyv1beta1.Backups {
if b.Enabled != nil && !*b.Enabled {
return crunchyv1beta1.Backups{}
}
| } | ||
|
|
||
| bcp.Status.State = v2.BackupFailed | ||
| bcp.Status.Error = "Backups are not enabled in the PerconaPGCluster configuration" |
There was a problem hiding this comment.
Maybe we can add one more state like skipped or disabled? Technically it's not failed it's just disabled.
There was a problem hiding this comment.
In K8SPSMDB we also set backup state to Failed if cluster is not ready. I don't think we need to complicate things.
commit: bbbe9cc |
CHANGE DESCRIPTION
This PR allows creating a PerconaPGCluster with backups disabled. To create a cluster with backups disabled, remove
spec.backupssection fromdeploy/cr.yamland apply.If you want to disable backups in a running cluster, you need to annotate PerconaPGCluster with
pgv2.percona.com/authorizeBackupRemoval: trueotherwise operator won't reconcile cluster and backup related objects won't be removed.Once backups are disabled, operator will delete repo-host PVC. So any backups stored in that PVC will be deleted. Backups in cloud storages won't be deleted.
Helm chart PR: percona/percona-helm-charts#516
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability