Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rdb): allow updates from bssd to lssd if new node type has enough space #2461

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions scaleway/resource_rdb_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,18 @@ func resourceScalewayRdbInstanceUpdate(ctx context.Context, d *schema.ResourceDa
})
}

// If we are switching to local storage, we have to make sure that the node_type upgrade is done first
if d.HasChange("volume_type") {
wantedVolumeType := d.Get("volume_type")
if wantedVolumeType == rdb.VolumeTypeLssd.String() {
for i, req := range upgradeInstanceRequests {
if req.NodeType != nil && i != 0 {
upgradeInstanceRequests[0], upgradeInstanceRequests[i] = upgradeInstanceRequests[i], upgradeInstanceRequests[0]
}
}
}
}

// Carry out the upgrades
for i := range upgradeInstanceRequests {
_, err = waitForRDBInstance(ctx, rdbAPI, region, ID, d.Timeout(schema.TimeoutUpdate))
Expand Down
19 changes: 19 additions & 0 deletions scaleway/resource_rdb_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,25 @@ func TestAccScalewayRdbInstance_Volume(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "volume_size_in_gb", "10"),
),
},
{
Config: fmt.Sprintf(`
resource scaleway_rdb_instance main {
name = "test-rdb-instance-volume"
node_type = "db-dev-m"
engine = %q
is_ha_cluster = false
disable_backup = true
user_name = "my_initial_user"
password = "thiZ_is_v&ry_s3cret"
region= "nl-ams"
tags = [ "terraform-test", "scaleway_rdb_instance", "volume" ]
}
`, latestEngineVersion),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalewayRdbExists(tt, "scaleway_rdb_instance.main"),
resource.TestCheckResourceAttr("scaleway_rdb_instance.main", "volume_type", "lssd"),
),
},
},
})
}
Expand Down