diff --git a/ibm/service/database/resource_ibm_database.go b/ibm/service/database/resource_ibm_database.go index b5fb8e7500..dc3723ca51 100644 --- a/ibm/service/database/resource_ibm_database.go +++ b/ibm/service/database/resource_ibm_database.go @@ -1817,7 +1817,14 @@ func resourceIBMDatabaseInstanceRead(context context.Context, d *schema.Resource return diag.FromErr(fmt.Errorf("[ERROR] Error setting the database configuration schema: %s", err)) } } + + // This can be removed any time after August once all old multitenant instances are switched over to the new multitenant + if groupList.Groups[0].HostFlavor == nil && (groupList.Groups[0].CPU != nil && *groupList.Groups[0].CPU.AllocationCount == 0) { + return appendSwitchoverWarning() + } + return nil + } func resourceIBMDatabaseInstanceUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { @@ -2897,8 +2904,22 @@ func validateMultitenantMemoryCpu(resourceDefaults *Group, group *Group, cpuEnfo if group.CPU.Allocation >= cpuEnforcementRatioCeilingTemp/cpuEnforcementRatioMb { return nil } else { - return fmt.Errorf("The current cpu alloaction of %d is not valid for your current configuration.", group.CPU.Allocation) + return fmt.Errorf("The current cpu allocation of %d is not valid for your current configuration.", group.CPU.Allocation) + } +} + +// This can be removed any time after August once all old multitenant instances are switched over to the new multitenant +func appendSwitchoverWarning() diag.Diagnostics { + var diags diag.Diagnostics + + warning := diag.Diagnostic{ + Severity: diag.Warning, + Summary: "Note: IBM Cloud Databases released new Hosting Models on May 1. All existing multi-tenant instances will have their resources adjusted to Shared Compute allocations during August 2024. To monitor your current resource needs, and learn about how the transition to Shared Compute will impact your instance, see our documentation https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hosting-models", } + + diags = append(diags, warning) + + return diags } func validateGroupsDiff(_ context.Context, diff *schema.ResourceDiff, meta interface{}) (err error) { diff --git a/ibm/service/database/resource_ibm_database_test.go b/ibm/service/database/resource_ibm_database_test.go index 5e58458d58..81090ce690 100644 --- a/ibm/service/database/resource_ibm_database_test.go +++ b/ibm/service/database/resource_ibm_database_test.go @@ -4,9 +4,11 @@ package database import ( + "testing" + "github.com/IBM/go-sdk-core/v5/core" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "gotest.tools/assert" - "testing" ) func TestValidateUserPassword(t *testing.T) { @@ -193,3 +195,20 @@ func TestValidateRBACRole(t *testing.T) { } } } + +func TestAppendSwitchoverWarning(t *testing.T) { + diags := appendSwitchoverWarning() + warningNote := "Note: IBM Cloud Databases released new Hosting Models on May 1. All existing multi-tenant instances will have their resources adjusted to Shared Compute allocations during August 2024. To monitor your current resource needs, and learn about how the transition to Shared Compute will impact your instance, see our documentation https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hosting-models" + + if len(diags) != 1 { + t.Fatalf("expected 1 diagnostic, got %d", len(diags)) + } + + if diags[0].Severity != diag.Warning { + t.Errorf("expected severity %v, got %v", diag.Warning, diags[0].Severity) + } + + if diags[0].Summary != warningNote { + t.Errorf("expected summary %v, got %v", warningNote, diags[0].Summary) + } +}