Skip to content

Commit c722762

Browse files
committed
fix: global data persistance should be computed, adding tflog for debugging
1 parent 1bf4cd4 commit c722762

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

provider/resource_rediscloud_active_active_database.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/RedisLabs/terraform-provider-rediscloud/provider/pro"
1414
"github.com/RedisLabs/terraform-provider-rediscloud/provider/utils"
1515
"github.com/hashicorp/go-cty/cty"
16+
"github.com/hashicorp/terraform-plugin-log/tflog"
1617
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1718
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1819
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -149,6 +150,7 @@ func resourceRedisCloudActiveActiveDatabase() *schema.Resource {
149150
Description: "Rate of database data persistence (in persistent storage)",
150151
Type: schema.TypeString,
151152
Optional: true,
153+
Computed: true,
152154
},
153155
"global_password": {
154156
Description: "Password used to access the database. If left empty, the password will be generated automatically",
@@ -637,7 +639,11 @@ func resourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema.R
637639
globalEnableDefaultUser := d.Get("global_enable_default_user").(bool)
638640
regionEnableDefaultUser := redis.BoolValue(regionDb.Security.EnableDefaultUser)
639641

640-
log.Printf("[DEBUG] Read enable_default_user for region %s: region=%v, global=%v", region, regionEnableDefaultUser, globalEnableDefaultUser)
642+
tflog.Debug(ctx, "Read enable_default_user for region", map[string]interface{}{
643+
"region": region,
644+
"region_value": regionEnableDefaultUser,
645+
"global_value": globalEnableDefaultUser,
646+
})
641647

642648
// Check if GetRawConfig is available (during Apply/Update)
643649
rawConfig := d.GetRawConfig()
@@ -649,7 +655,10 @@ func resourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema.R
649655
if getRawConfigAvailable {
650656
// Config-based mode: Check if explicitly set in config
651657
wasExplicitlySet := isEnableDefaultUserExplicitlySetInConfig(d, region)
652-
log.Printf("[DEBUG] Config-based detection for region %s: wasExplicitlySet=%v", region, wasExplicitlySet)
658+
tflog.Debug(ctx, "Config-based detection for region", map[string]interface{}{
659+
"region": region,
660+
"wasExplicitlySet": wasExplicitlySet,
661+
})
653662

654663
if wasExplicitlySet {
655664
shouldInclude = true
@@ -664,7 +673,10 @@ func resourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema.R
664673
} else {
665674
// State-based mode: Check if was in actual persisted state
666675
fieldWasInActualState := isEnableDefaultUserInActualPersistedState(d, region)
667-
log.Printf("[DEBUG] State-based detection for region %s: fieldWasInActualState=%v", region, fieldWasInActualState)
676+
tflog.Debug(ctx, "State-based detection for region", map[string]interface{}{
677+
"region": region,
678+
"fieldWasInActualState": fieldWasInActualState,
679+
})
668680

669681
if fieldWasInActualState {
670682
shouldInclude = true
@@ -678,7 +690,11 @@ func resourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema.R
678690
}
679691
}
680692

681-
log.Printf("[DEBUG] enable_default_user decision for region %s: shouldInclude=%v, reason=%s", region, shouldInclude, reason)
693+
tflog.Debug(ctx, "enable_default_user decision for region", map[string]interface{}{
694+
"region": region,
695+
"shouldInclude": shouldInclude,
696+
"reason": reason,
697+
})
682698

683699
if shouldInclude {
684700
regionDbConfig["enable_default_user"] = regionEnableDefaultUser
@@ -811,11 +827,16 @@ func resourceRedisCloudActiveActiveDatabaseUpdate(ctx context.Context, d *schema
811827
// User explicitly set it in config - send the value
812828
if val, exists := dbRegion["enable_default_user"]; exists && val != nil {
813829
regionProps.EnableDefaultUser = redis.Bool(val.(bool))
814-
log.Printf("[DEBUG] Update: Sending enable_default_user=%v for region %s (explicitly set)", val, regionName)
830+
tflog.Debug(ctx, "Update: Sending enable_default_user for region (explicitly set)", map[string]interface{}{
831+
"region": regionName,
832+
"value": val,
833+
})
815834
}
816835
} else {
817836
// Not explicitly set - don't send field, API will use global
818-
log.Printf("[DEBUG] Update: NOT sending enable_default_user for region %s (inherits from global)", regionName)
837+
tflog.Debug(ctx, "Update: NOT sending enable_default_user for region (inherits from global)", map[string]interface{}{
838+
"region": regionName,
839+
})
819840
}
820841

821842
if len(overrideAlerts) > 0 {

0 commit comments

Comments
 (0)