Skip to content

Commit

Permalink
chore(AwsRedisInstance): add shardcount to client (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
dushanpantic authored Feb 18, 2025
1 parent e9ebf88 commit d39a49f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/kcp/provider/aws/client/elastiCacheClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type CreateElastiCacheClusterOptions struct {
AuthTokenSecretString *string
PreferredMaintenanceWindow *string
SecurityGroupIds []string
ReplicasPerNodeGroup int32
ReplicasPerNodeGroup int32 // replicas per shard
ShardCount *int32
}

type ModifyElastiCacheClusterOptions struct {
Expand Down Expand Up @@ -316,14 +317,21 @@ func (c *client) DescribeElastiCacheReplicationGroup(ctx context.Context, cluste

func (c *client) CreateElastiCacheReplicationGroup(ctx context.Context, tags []elasticacheTypes.Tag, options CreateElastiCacheClusterOptions) (*elasticache.CreateReplicationGroupOutput, error) {
automaticFailoverEnabled := options.ReplicasPerNodeGroup > 0

shardCount := ptr.Deref(options.ShardCount, 1)
clusterMode := elasticacheTypes.ClusterModeDisabled
if shardCount > 1 {
clusterMode = elasticacheTypes.ClusterModeEnabled
}

params := &elasticache.CreateReplicationGroupInput{
ReplicationGroupId: aws.String(options.Name),
ReplicationGroupDescription: aws.String("ElastiCache managed by Kyma Cloud Manager"),
CacheSubnetGroupName: aws.String(options.SubnetGroupName),
CacheParameterGroupName: aws.String(options.ParameterGroupName),
CacheNodeType: aws.String(options.CacheNodeType),
NumNodeGroups: aws.Int32(1),
ClusterMode: elasticacheTypes.ClusterModeDisabled,
NumNodeGroups: aws.Int32(shardCount),
ClusterMode: clusterMode,
Engine: aws.String("redis"),
EngineVersion: aws.String(options.EngineVersion),
AutoMinorVersionUpgrade: aws.Bool(options.AutoMinorVersionUpgrade),
Expand Down
4 changes: 4 additions & 0 deletions pkg/kcp/provider/aws/mock/elastiCacheClientFake.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ func (client *elastiCacheClientFake) CreateElastiCacheReplicationGroup(ctx conte
UserGroupIds: []string{},
Engine: ptr.To("redis"),
AtRestEncryptionEnabled: ptr.To(true),
ConfigurationEndpoint: &elasticacheTypes.Endpoint{
Address: ptr.To("192.168.3.2"),
Port: aws.Int32(6949),
},
NodeGroups: []elasticacheTypes.NodeGroup{
{
PrimaryEndpoint: &elasticacheTypes.Endpoint{
Expand Down

0 comments on commit d39a49f

Please sign in to comment.