Skip to content

Commit

Permalink
Merge pull request IBM-Cloud#5395 from lornakelly/1247/switchover-not…
Browse files Browse the repository at this point in the history
…ification
  • Loading branch information
omaraibrahim authored May 30, 2024
2 parents 52bd9c4 + ed01780 commit f19d2b8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
23 changes: 22 additions & 1 deletion ibm/service/database/resource_ibm_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 20 additions & 1 deletion ibm/service/database/resource_ibm_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit f19d2b8

Please sign in to comment.