From 19b495e753505acdc521f46238744d6932d4e4f6 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Wed, 18 Dec 2024 17:30:22 +0600 Subject: [PATCH] Fix availabilityGroup panic; Set defults to logBackupOptions Signed-off-by: Arnob kumar saha --- apis/archiver/v1alpha1/helpers.go | 10 ++++++++++ apis/kubedb/v1alpha2/mssqlserver_helpers.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/apis/archiver/v1alpha1/helpers.go b/apis/archiver/v1alpha1/helpers.go index e097263e63..789e2e19bc 100644 --- a/apis/archiver/v1alpha1/helpers.go +++ b/apis/archiver/v1alpha1/helpers.go @@ -45,3 +45,13 @@ func (_ MariaDBArchiver) CustomResourceDefinition() *apiextensions.CustomResourc func (_ MSSQLServerArchiver) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralMSSQLServerArchiver)) } + +func SetDefaultLogBackupOptions(log *LogBackupOptions) *LogBackupOptions { + if log == nil { + log = &LogBackupOptions{ + SuccessfulLogHistoryLimit: 5, + FailedLogHistoryLimit: 5, + } + } + return log +} diff --git a/apis/kubedb/v1alpha2/mssqlserver_helpers.go b/apis/kubedb/v1alpha2/mssqlserver_helpers.go index 16194974eb..9eb763a93d 100644 --- a/apis/kubedb/v1alpha2/mssqlserver_helpers.go +++ b/apis/kubedb/v1alpha2/mssqlserver_helpers.go @@ -343,6 +343,9 @@ func (m *MSSQLServer) SetDefaults() { m.Spec.Replicas = pointer.Int32P(1) } } else if m.IsAvailabilityGroup() { + if m.Spec.Topology.AvailabilityGroup == nil { + m.Spec.Topology.AvailabilityGroup = &MSSQLServerAvailabilityGroupSpec{} + } if m.Spec.Topology.AvailabilityGroup.LeaderElection == nil { m.Spec.Topology.AvailabilityGroup.LeaderElection = &MSSQLServerLeaderElectionConfig{ // The upper limit of election timeout is 50000ms (50s), which should only be used when deploying a