Skip to content

Commit 2add654

Browse files
Merge pull request #691 from RedisLabs/feat/auto-upgrade-minor
Auto Minor Version Upgrade
2 parents 82a968b + fc97c54 commit 2add654

19 files changed

+343
-77
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
# Initializes the CodeQL tools for scanning.
4242
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v3
43+
uses: github/codeql-action/init@v4
4444
with:
4545
languages: ${{ matrix.language }}
4646
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,7 +51,7 @@ jobs:
5151
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5252
# If this step fails, then you should remove it and run the build manually (see below)
5353
- name: Autobuild
54-
uses: github/codeql-action/autobuild@v3
54+
uses: github/codeql-action/autobuild@v4
5555

5656
# ℹ️ Command-line programs to run using the OS shell.
5757
# 📚 https://git.io/JvXDl
@@ -65,4 +65,4 @@ jobs:
6565
# make release
6666

6767
- name: Perform CodeQL Analysis
68-
uses: github/codeql-action/analyze@v3
68+
uses: github/codeql-action/analyze@v4

.github/workflows/terraform_provider_main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ jobs:
185185
runs-on: ubuntu-latest
186186
steps:
187187
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
188-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
188+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
189189
with:
190190
go-version-file: go.mod
191191
- run: go test ./... -run="^TestUnit" # Runs tests starting with TestUnit

.github/workflows/terraform_provider_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
runs-on: ubuntu-latest
200200
steps:
201201
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
202-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
202+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
203203
with:
204204
go-version-file: go.mod
205205
- run: go test ./... -run="^TestUnit" # Runs tests starting with TestUnit

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
All notable changes to this project will be documented in this file.
44
See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
55

6+
# 2.7.0 (22nd October 2025)
7+
8+
## Added:
9+
- Add auto_minor_version_upgrade field to Pro and Active-Active database resources (default: true) to allow users to control automatic minor version upgrades. This will NOT affect existing databases.
10+
11+
## Changed:
12+
- Change Redis 8.0 modules validation from hard error to warning since modules are bundled by default in Redis 8+.
13+
14+
## Fixed:
15+
- Fix test error message patterns to match updated API error format.
16+
- Fix Redis 8 upgrade test expectation (dataset_size_in_gb: 3→1).
17+
18+
619
# 2.6.0 (17th October 2025)
720

821
## Added:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.0
55
toolchain go1.24.1
66

77
require (
8-
github.com/RedisLabs/rediscloud-go-api v0.38.0
8+
github.com/RedisLabs/rediscloud-go-api v0.39.0
99
github.com/bflad/tfproviderlint v0.31.0
1010
github.com/hashicorp/go-cty v1.5.0
1111
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
44
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
55
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
66
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
7-
github.com/RedisLabs/rediscloud-go-api v0.38.0 h1:lLOS0E8tQhUzuUfb/H+QWtDaZrC9xNnTvAPBygH4WS8=
8-
github.com/RedisLabs/rediscloud-go-api v0.38.0/go.mod h1:Hkh3i/EsHnyfgV0ijednbofz/EmZC3sFnSNNruF3G6I=
7+
github.com/RedisLabs/rediscloud-go-api v0.39.0 h1:VNI7VyP9V41Z8FP558v60WCJFBB57AGuQQq3QY4t2VU=
8+
github.com/RedisLabs/rediscloud-go-api v0.39.0/go.mod h1:Hkh3i/EsHnyfgV0ijednbofz/EmZC3sFnSNNruF3G6I=
99
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
1010
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
1111
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
}
5+
6+
data "rediscloud_payment_method" "card" {
7+
card_type = "Visa"
8+
last_four_numbers = "5556"
9+
}
10+
11+
data "rediscloud_cloud_account" "account" {
12+
exclude_internal_account = true
13+
provider_type = "AWS"
14+
name = local.rediscloud_cloud_account
15+
}
16+
17+
resource "rediscloud_active_active_subscription" "example" {
18+
name = local.rediscloud_subscription_name
19+
payment_method_id = data.rediscloud_payment_method.card.id
20+
storage_encryption = true
21+
22+
region {
23+
region = "eu-west-1"
24+
networking_deployment_cidr = "10.0.0.0/24"
25+
preferred_availability_zones = ["eu-west-1a"]
26+
}
27+
28+
region {
29+
region = "us-east-1"
30+
networking_deployment_cidr = "10.1.0.0/24"
31+
preferred_availability_zones = ["us-east-1a"]
32+
}
33+
}
34+
35+
resource "rediscloud_active_active_subscription_database" "example" {
36+
subscription_id = rediscloud_active_active_subscription.example.id
37+
name = "auto-minor-version-upgrade-test"
38+
protocol = "redis"
39+
dataset_size_in_gb = 1
40+
data_eviction = "allkeys-random"
41+
throughput_measurement_by = "operations-per-second"
42+
throughput_measurement_value = 1000
43+
auto_minor_version_upgrade = %s
44+
}

provider/pro/resource_rediscloud_pro_database.go

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ func ResourceRedisCloudProDatabase() *schema.Resource {
297297
Optional: true,
298298
Default: true,
299299
},
300+
"auto_minor_version_upgrade": {
301+
Description: "When 'true', enables auto minor version upgrades for this database. Default: 'true'",
302+
Type: schema.TypeBool,
303+
Optional: true,
304+
Default: true,
305+
},
300306
"port": {
301307
Description: "TCP port on which the database is available",
302308
Type: schema.TypeInt,
@@ -436,8 +442,13 @@ func resourceRedisCloudProDatabaseCreate(ctx context.Context, d *schema.Resource
436442
createDatabase.RespVersion = s
437443
})
438444

445+
utils.SetBool(d, "auto_minor_version_upgrade", func(b *bool) {
446+
createDatabase.AutoMinorVersionUpgrade = b
447+
})
448+
439449
// Confirm sub is ready to accept a db request
440450
if err := utils.WaitForSubscriptionToBeActive(ctx, subId, api); err != nil {
451+
utils.SubscriptionMutex.Unlock(subId)
441452
return diag.FromErr(err)
442453
}
443454

@@ -656,6 +667,10 @@ func resourceRedisCloudProDatabaseRead(ctx context.Context, d *schema.ResourceDa
656667
}
657668
}
658669

670+
if err := d.Set("auto_minor_version_upgrade", redis.BoolValue(db.AutoMinorVersionUpgrade)); err != nil {
671+
return diag.FromErr(err)
672+
}
673+
659674
if err := ReadTags(ctx, api, subId, dbId, d); err != nil {
660675
return diag.FromErr(err)
661676
}
@@ -731,12 +746,13 @@ func resourceRedisCloudProDatabaseUpdate(ctx context.Context, d *schema.Resource
731746
Value: utils.GetInt(d, "throughput_measurement_value"),
732747
},
733748

734-
DataPersistence: utils.GetString(d, "data_persistence"),
735-
DataEvictionPolicy: utils.GetString(d, "data_eviction"),
736-
SourceIP: utils.SetToStringSlice(d.Get("source_ips").(*schema.Set)),
737-
Alerts: &alerts,
738-
RemoteBackup: BuildBackupPlan(d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path")),
739-
EnableDefaultUser: utils.GetBool(d, "enable_default_user"),
749+
DataPersistence: utils.GetString(d, "data_persistence"),
750+
DataEvictionPolicy: utils.GetString(d, "data_eviction"),
751+
SourceIP: utils.SetToStringSlice(d.Get("source_ips").(*schema.Set)),
752+
Alerts: &alerts,
753+
RemoteBackup: BuildBackupPlan(d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path")),
754+
EnableDefaultUser: utils.GetBool(d, "enable_default_user"),
755+
AutoMinorVersionUpgrade: utils.GetBool(d, "auto_minor_version_upgrade"),
740756
}
741757

742758
// One of the following fields must be set, validation is handled in the schema (ExactlyOneOf)
@@ -1037,19 +1053,32 @@ func containsDBModule(modules []map[string]interface{}, moduleName string) bool
10371053
return false
10381054
}
10391055

1056+
// shouldWarnRedis8Modules checks if a warning should be issued for modules in Redis 8.0 or higher
1057+
func shouldWarnRedis8Modules(version string, hasModules bool) bool {
1058+
if !hasModules {
1059+
return false
1060+
}
1061+
// Extract major version (first character before the dot)
1062+
if len(version) > 0 {
1063+
majorVersionStr := strings.Split(version, ".")[0]
1064+
if majorVersion, err := strconv.Atoi(majorVersionStr); err == nil {
1065+
return majorVersion >= 8
1066+
}
1067+
}
1068+
return false
1069+
}
1070+
10401071
func validateModulesForRedis8() schema.CustomizeDiffFunc {
10411072
return func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error {
10421073
redisVersion, versionExists := diff.GetOk("redis_version")
10431074
modules, modulesExists := diff.GetOkExists("modules")
10441075

10451076
if versionExists && modulesExists {
10461077
version := redisVersion.(string)
1047-
// Check if version is >= 8.0
1048-
if strings.HasPrefix(version, "8.") {
1049-
moduleSet := modules.(*schema.Set)
1050-
if moduleSet.Len() > 0 {
1051-
return fmt.Errorf(`"modules" cannot be explicitly set for Redis version %s as modules are bundled by default. Remove the "modules" field from your configuration`, version)
1052-
}
1078+
moduleSet := modules.(*schema.Set)
1079+
1080+
if shouldWarnRedis8Modules(version, moduleSet.Len() > 0) {
1081+
log.Printf("[WARN] Modules are bundled by default in Redis %s. You should remove the modules block as it is deprecated for this version.", version)
10531082
}
10541083
}
10551084
return nil
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package pro
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
// TestUnitShouldWarnRedis8Modules_Redis8WithModules tests that warning is triggered for Redis 8.0 with modules
10+
func TestUnitShouldWarnRedis8Modules_Redis8WithModules(t *testing.T) {
11+
result := shouldWarnRedis8Modules("8.0", true)
12+
assert.True(t, result, "should warn for Redis 8.0 with modules")
13+
}
14+
15+
// TestUnitShouldWarnRedis8Modules_Redis80WithModules tests that warning is triggered for Redis 8.0.0 with modules
16+
func TestUnitShouldWarnRedis8Modules_Redis80WithModules(t *testing.T) {
17+
result := shouldWarnRedis8Modules("8.0.0", true)
18+
assert.True(t, result, "should warn for Redis 8.0.0 with modules")
19+
}
20+
21+
// TestUnitShouldWarnRedis8Modules_Redis81WithModules tests that warning is triggered for Redis 8.1+ with modules
22+
func TestUnitShouldWarnRedis8Modules_Redis81WithModules(t *testing.T) {
23+
result := shouldWarnRedis8Modules("8.1.0", true)
24+
assert.True(t, result, "should warn for Redis 8.1.0 with modules")
25+
}
26+
27+
// TestUnitShouldWarnRedis8Modules_Redis89WithModules tests that warning is triggered for Redis 8.9+ with modules
28+
func TestUnitShouldWarnRedis8Modules_Redis89WithModules(t *testing.T) {
29+
result := shouldWarnRedis8Modules("8.9.9", true)
30+
assert.True(t, result, "should warn for Redis 8.9.9 with modules")
31+
}
32+
33+
// TestUnitShouldWarnRedis8Modules_Redis7WithModules tests that no warning for Redis 7.x with modules
34+
func TestUnitShouldWarnRedis8Modules_Redis7WithModules(t *testing.T) {
35+
result := shouldWarnRedis8Modules("7.4", true)
36+
assert.False(t, result, "should not warn for Redis 7.4 with modules")
37+
}
38+
39+
// TestUnitShouldWarnRedis8Modules_Redis6WithModules tests that no warning for Redis 6.x with modules
40+
func TestUnitShouldWarnRedis8Modules_Redis6WithModules(t *testing.T) {
41+
result := shouldWarnRedis8Modules("6.2", true)
42+
assert.False(t, result, "should not warn for Redis 6.2 with modules")
43+
}
44+
45+
// TestUnitShouldWarnRedis8Modules_Redis8NoModules tests that no warning for Redis 8.0 without modules
46+
func TestUnitShouldWarnRedis8Modules_Redis8NoModules(t *testing.T) {
47+
result := shouldWarnRedis8Modules("8.0", false)
48+
assert.False(t, result, "should not warn for Redis 8.0 without modules")
49+
}
50+
51+
// TestUnitShouldWarnRedis8Modules_Redis7NoModules tests that no warning for Redis 7.x without modules
52+
func TestUnitShouldWarnRedis8Modules_Redis7NoModules(t *testing.T) {
53+
result := shouldWarnRedis8Modules("7.4", false)
54+
assert.False(t, result, "should not warn for Redis 7.4 without modules")
55+
}
56+
57+
// TestUnitShouldWarnRedis8Modules_Redis9WithModules tests that warning is triggered for Redis 9.x with modules (future-proofing)
58+
func TestUnitShouldWarnRedis8Modules_Redis9WithModules(t *testing.T) {
59+
result := shouldWarnRedis8Modules("9.0", true)
60+
assert.True(t, result, "should warn for Redis 9.0 with modules (modules bundled in 8.0+)")
61+
}
62+
63+
// TestUnitShouldWarnRedis8Modules_Redis10WithModules tests that warning is triggered for Redis 10.x with modules
64+
func TestUnitShouldWarnRedis8Modules_Redis10WithModules(t *testing.T) {
65+
result := shouldWarnRedis8Modules("10.0.0", true)
66+
assert.True(t, result, "should warn for Redis 10.0.0 with modules (modules bundled in 8.0+)")
67+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
locals {
2+
rediscloud_cloud_account = "%s"
3+
rediscloud_subscription_name = "%s"
4+
auto_minor_version_upgrade = %s
5+
}
6+
7+
data "rediscloud_payment_method" "card" {
8+
card_type = "Visa"
9+
last_four_numbers = "5556"
10+
}
11+
12+
data "rediscloud_cloud_account" "account" {
13+
exclude_internal_account = true
14+
provider_type = "AWS"
15+
name = local.rediscloud_cloud_account
16+
}
17+
18+
resource "rediscloud_subscription" "example" {
19+
name = local.rediscloud_subscription_name
20+
payment_method_id = data.rediscloud_payment_method.card.id
21+
memory_storage = "ram"
22+
cloud_provider {
23+
provider = data.rediscloud_cloud_account.account.provider_type
24+
cloud_account_id = data.rediscloud_cloud_account.account.id
25+
region {
26+
region = "eu-west-1"
27+
networking_deployment_cidr = "10.0.0.0/24"
28+
preferred_availability_zones = ["eu-west-1a"]
29+
}
30+
}
31+
32+
creation_plan {
33+
memory_limit_in_gb = 1
34+
quantity = 1
35+
replication = false
36+
throughput_measurement_by = "operations-per-second"
37+
throughput_measurement_value = 1000
38+
}
39+
}
40+
41+
resource "rediscloud_subscription_database" "example" {
42+
subscription_id = rediscloud_subscription.example.id
43+
name = "auto-minor-version-upgrade-test"
44+
protocol = "redis"
45+
memory_limit_in_gb = 1
46+
data_persistence = "none"
47+
throughput_measurement_by = "operations-per-second"
48+
throughput_measurement_value = 1000
49+
auto_minor_version_upgrade = local.auto_minor_version_upgrade
50+
}

0 commit comments

Comments
 (0)