From a1bbfd9d9a2c215e54de800e81e91a16b35a4a87 Mon Sep 17 00:00:00 2001 From: Raphael Torquato <89878688+raphaeltorquat0@users.noreply.github.com> Date: Wed, 3 Jun 2026 08:00:51 -0300 Subject: [PATCH] Fix bool config defaults when using OperatorConfiguration CRD (#3084) * Fix bool config defaults when using OperatorConfiguration CRD When using OperatorConfiguration CRD, boolean fields with default value of `true` (like `enable_database_access` and `debug_logging`) were incorrectly defaulting to `false` when not explicitly specified. This happened because Go initializes bool fields to `false`, and there was no coalesce logic to apply the intended defaults. The fix changes the CRD type fields from `bool` to `*bool` (pointer), allowing us to distinguish between "not specified" (nil) and "explicitly set to false". Then we use the existing `CoalesceBool` utility function to apply the correct defaults. Fixes #2575 * update generated code Updated DeepCopyInto method for OperatorDebugConfiguration to handle pointers for DebugLogging and EnableDBAccess. --------- Co-authored-by: Felix Kunde --- .../acid.zalan.do/v1/operator_configuration_type.go | 4 ++-- pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go | 12 +++++++++++- pkg/controller/operator_config.go | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index 787a97253..0087e5850 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -168,8 +168,8 @@ type AWSGCPConfiguration struct { // OperatorDebugConfiguration defines options for the debug mode type OperatorDebugConfiguration struct { - DebugLogging bool `json:"debug_logging,omitempty"` - EnableDBAccess bool `json:"enable_database_access,omitempty"` + DebugLogging *bool `json:"debug_logging,omitempty"` + EnableDBAccess *bool `json:"enable_database_access,omitempty"` } // TeamsAPIConfiguration defines the configuration of TeamsAPI diff --git a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go index da4a18626..3fdc31fa7 100644 --- a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go +++ b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go @@ -476,7 +476,7 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData out.Timeouts = in.Timeouts in.LoadBalancer.DeepCopyInto(&out.LoadBalancer) out.AWSGCP = in.AWSGCP - out.OperatorDebug = in.OperatorDebug + in.OperatorDebug.DeepCopyInto(&out.OperatorDebug) in.TeamsAPI.DeepCopyInto(&out.TeamsAPI) out.LoggingRESTAPI = in.LoggingRESTAPI out.Scalyr = in.Scalyr @@ -532,6 +532,16 @@ func (in *OperatorConfigurationList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OperatorDebugConfiguration) DeepCopyInto(out *OperatorDebugConfiguration) { *out = *in + if in.DebugLogging != nil { + in, out := &in.DebugLogging, &out.DebugLogging + *out = new(bool) + **out = **in + } + if in.EnableDBAccess != nil { + in, out := &in.EnableDBAccess, &out.EnableDBAccess + *out = new(bool) + **out = **in + } return } diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 2b9cd9065..e304c14a5 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -215,8 +215,8 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.LogicalBackupMemoryLimit = fromCRD.LogicalBackup.MemoryLimit // debug config - result.DebugLogging = fromCRD.OperatorDebug.DebugLogging - result.EnableDBAccess = fromCRD.OperatorDebug.EnableDBAccess + result.DebugLogging = *util.CoalesceBool(fromCRD.OperatorDebug.DebugLogging, util.True()) + result.EnableDBAccess = *util.CoalesceBool(fromCRD.OperatorDebug.EnableDBAccess, util.True()) // Teams API config result.EnableTeamsAPI = fromCRD.TeamsAPI.EnableTeamsAPI