Skip to content

Commit

Permalink
feat: [Redis] add support for data tiering nodes (#783)
Browse files Browse the repository at this point in the history
* feat: [Redis] add support for data tiering nodes

[#184160811](https://www.pivotaltracker.com/story/show/184160811)

* chore: improve description

[#184160811](https://www.pivotaltracker.com/story/show/184160811)
  • Loading branch information
zucchinidev authored Mar 15, 2023
1 parent 4b8b288 commit 92b97d6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 22 deletions.
14 changes: 12 additions & 2 deletions aws-redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ provision:
type: string
details: AWS Elasticache node type (see https://aws.amazon.com/elasticache/pricing)
default: ""
# `node_type` is required by the provider but we can't specify it as such
# `node_type` is required by the provider, but we can't specify it as such
# in this manifest because we need to support passing `cache_size` without
# any `node_type` for backward compatibility. If `node_type` isn't specified
# in the plan nor at rovisioning time, provisioning will throw this error:
# in the plan nor at provisioning time, provisioning will throw this error:
# "node_type" is required unless "global_replication_group_id"
- field_name: elasticache_subnet_group
type: string
Expand All @@ -94,6 +94,16 @@ provision:
details: Whether to enable encryption at rest.
default: true
prohibit_update: true
- field_name: data_tiering_enabled
type: boolean
details: |
Enables data tiering. Data tiering is only supported for replication groups using the r6gd node type.
This parameter must be set to true when using `r6gd` nodes.
Not all versions of Redis support this feature. Check supported versions.
For more information about Node Types and supported Redis versions see
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheNodes.SupportedTypes.html
default: false
prohibit_update: true
- field_name: kms_key_id
type: string
details: The ARN of the key to use if encrypting at rest. Defaults to AWS managed key.
Expand Down
61 changes: 41 additions & 20 deletions integration-tests/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ import (
)

const (
redisServiceID = "e9c11b1b-0caa-45c9-b9b2-592939c9a5a6"
redisServiceName = "csb-aws-redis"
redisServiceDescription = "Beta - CSB Amazon ElastiCache for Redis - multinode with automatic failover"
redisServiceDisplayName = "CSB Amazon ElastiCache for Redis (Beta)"
redisServiceDocumentationURL = "https://docs.vmware.com/en/Tanzu-Cloud-Service-Broker-for-AWS/1.2/csb-aws/GUID-reference-aws-redis.html"
redisServiceSupportURL = "https://aws.amazon.com/redis/"
redisServiceProviderDisplayName = "VMware"
redisCustomPlanName = "custom-sample"
redisCustomPlanID = "c7f64994-a1d9-4e1f-9491-9d8e56bbf146"
redisServiceID = "e9c11b1b-0caa-45c9-b9b2-592939c9a5a6"
redisServiceName = "csb-aws-redis"
redisServiceDescription = "Beta - CSB Amazon ElastiCache for Redis - multinode with automatic failover"
redisServiceDisplayName = "CSB Amazon ElastiCache for Redis (Beta)"
redisServiceDocumentationURL = "https://docs.vmware.com/en/Tanzu-Cloud-Service-Broker-for-AWS/1.2/csb-aws/GUID-reference-aws-redis.html"
redisServiceSupportURL = "https://aws.amazon.com/redis/"
redisServiceProviderDisplayName = "VMware"
redisCustomPlanName = "custom-sample"
redisCustomPlanID = "c7f64994-a1d9-4e1f-9491-9d8e56bbf146"
deprecatedCacheSizePlanName = "deprecated-cachesize-sample"
deprecatedCacheSizePlanID = "eeae19c8-00c1-442d-b423-a377684b70df"
redisPlanWithFlexibleNodeTypePlanName = "flexible-nodetype-sample"
redisPlanWithFlexibleNodeTypePlanID = "2deb6c13-7ea1-4bad-a519-0ac9600e9a29"
)

var customRedisPlans = []map[string]any{
Expand All @@ -37,8 +41,8 @@ var customRedisPlan = map[string]any{
}

var redisPlanWithFlexibleNodeType = map[string]any{
"name": "flexible-nodetype-sample",
"id": "2deb6c13-7ea1-4bad-a519-0ac9600e9a29",
"name": redisPlanWithFlexibleNodeTypePlanName,
"id": redisPlanWithFlexibleNodeTypePlanID,
"description": "Beta - An example of a Redis plan for which node_type can be specified at provision time.",
"redis_version": "6.x",
"node_count": 2,
Expand All @@ -48,8 +52,8 @@ var redisPlanWithFlexibleNodeType = map[string]any{
}

var deprecatedCacheSizePlan = map[string]any{
"name": "deprecated-cachesize-sample",
"id": "eeae19c8-00c1-442d-b423-a377684b70df",
"name": deprecatedCacheSizePlanName,
"id": deprecatedCacheSizePlanID,
"description": "Beta - Redis plan with deprecated cache_size",
"cache_size": 2,
"redis_version": "6.x",
Expand Down Expand Up @@ -88,12 +92,12 @@ var _ = Describe("Redis", Label("Redis"), func() {
ID: Equal("c7f64994-a1d9-4e1f-9491-9d8e56bbf146"),
}),
MatchFields(IgnoreExtras, Fields{
Name: Equal("deprecated-cachesize-sample"),
ID: Equal("eeae19c8-00c1-442d-b423-a377684b70df"),
Name: Equal(deprecatedCacheSizePlanName),
ID: Equal(deprecatedCacheSizePlanID),
}),
MatchFields(IgnoreExtras, Fields{
Name: Equal("flexible-nodetype-sample"),
ID: Equal("2deb6c13-7ea1-4bad-a519-0ac9600e9a29"),
Name: Equal(redisPlanWithFlexibleNodeTypePlanName),
ID: Equal(redisPlanWithFlexibleNodeTypePlanID),
}),
),
)
Expand Down Expand Up @@ -164,12 +168,12 @@ var _ = Describe("Redis", Label("Redis"), func() {
)

It("should prevent passing the deprecated property `cache_size` as user input", func() {
_, err := broker.Provision(redisServiceName, "custom-sample", map[string]any{"cache_size": 2})
_, err := broker.Provision(redisServiceName, redisCustomPlanName, map[string]any{"cache_size": 2})
Expect(err).To(MatchError(ContainSubstring("additional properties are not allowed: cache_size")))
})

It("should keeping working as before for existing customers relying on `cache_size` property", func() {
_, err := broker.Provision(redisServiceName, "deprecated-cachesize-sample", map[string]any{})
_, err := broker.Provision(redisServiceName, deprecatedCacheSizePlanName, map[string]any{})
Expect(err).NotTo(HaveOccurred())

Expect(mockTerraform.FirstTerraformInvocationVars()).To(
Expand All @@ -179,7 +183,7 @@ var _ = Describe("Redis", Label("Redis"), func() {
})

It("should keeping working as before for existing customers relying on `cache_size` property and per-instance `node_type`", func() {
_, err := broker.Provision(redisServiceName, "deprecated-cachesize-sample", map[string]any{"node_type": "cache.t2.micro"})
_, err := broker.Provision(redisServiceName, deprecatedCacheSizePlanName, map[string]any{"node_type": "cache.t2.micro"})
Expect(err).NotTo(HaveOccurred())

Expect(mockTerraform.FirstTerraformInvocationVars()).To(
Expand Down Expand Up @@ -214,6 +218,7 @@ var _ = Describe("Redis", Label("Redis"), func() {
HaveKeyWithValue("maintenance_start_min", BeNil()),
HaveKeyWithValue("maintenance_end_hour", BeNil()),
HaveKeyWithValue("maintenance_end_min", BeNil()),
HaveKeyWithValue("data_tiering_enabled", BeFalse()),
))
})

Expand Down Expand Up @@ -260,6 +265,21 @@ var _ = Describe("Redis", Label("Redis"), func() {
),
)
})

It("`data_tiering_enabled` must be set to true when using `r6gd` nodes when provisioning", func() {
_, err := broker.Provision(redisServiceName, redisPlanWithFlexibleNodeTypePlanName, map[string]any{
"node_type": "cache.r6gd.xlarge",
"data_tiering_enabled": true,
})
Expect(err).NotTo(HaveOccurred())

Expect(mockTerraform.FirstTerraformInvocationVars()).To(
SatisfyAll(
HaveKeyWithValue("node_type", "cache.r6gd.xlarge"),
HaveKeyWithValue("data_tiering_enabled", true),
),
)
})
})

Describe("updating instance", func() {
Expand Down Expand Up @@ -290,6 +310,7 @@ var _ = Describe("Redis", Label("Redis"), func() {
Entry("instance_name", "instance_name", "any-valid-instance-name"),
Entry("at_rest_encryption_enabled", "at_rest_encryption_enabled", false),
Entry("kms_key_id", "kms_key_id", "fake-encryption-at-rest-key"),
Entry("data_tiering_enabled", "data_tiering_enabled", true),
)

It("preventing updates for `plan defined properties` by design", func() {
Expand Down
2 changes: 2 additions & 0 deletions terraform-tests/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var _ = Describe("Redis", Label("redis-terraform"), Ordered, func() {
"maintenance_end_min": nil,
"maintenance_start_min": nil,
"maintenance_day": nil,
"data_tiering_enabled": false,
}

BeforeAll(func() {
Expand Down Expand Up @@ -87,6 +88,7 @@ var _ = Describe("Redis", Label("redis-terraform"), Ordered, func() {
"snapshot_arns": BeNil(),
"tags_all": BeAssignableToTypeOf(map[string]any{}),
"user_group_ids": BeNil(),
"data_tiering_enabled": BeFalse(),
}))
})
})
Expand Down
1 change: 1 addition & 0 deletions terraform/redis/cluster/provision/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ resource "aws_elasticache_replication_group" "redis" {
at_rest_encryption_enabled = var.at_rest_encryption_enabled
kms_key_id = var.kms_key_id
maintenance_window = local.maintenance_window
data_tiering_enabled = var.data_tiering_enabled

lifecycle {
prevent_destroy = true
Expand Down
1 change: 1 addition & 0 deletions terraform/redis/cluster/provision/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ variable "maintenance_start_hour" { type = string }
variable "maintenance_start_min" { type = string }
variable "maintenance_end_hour" { type = string }
variable "maintenance_end_min" { type = string }
variable "data_tiering_enabled" { type = bool }

0 comments on commit 92b97d6

Please sign in to comment.