Skip to content

Commit cbe3158

Browse files
authored
Merge pull request #2096 from anagarlau/v0.49.0-patch
fix: attempt to fix the version problems of replicationgroups (#1)
2 parents b3c0d66 + 11a4b9d commit cbe3158

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

pkg/controller/cache/replicationgroup/managed.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,15 @@ func getVersion(version *string) (*string, error) {
364364
}
365365
versionOut := strconv.Itoa(version1)
366366
if len(versionSplit) > 1 {
367-
version2, err := strconv.Atoi(versionSplit[1])
368-
if err != nil {
369-
return nil, errors.Wrap(err, errVersionInput)
367+
if versionSplit[1] != "x" {
368+
version2, err := strconv.Atoi(versionSplit[1])
369+
if err != nil {
370+
return nil, errors.Wrap(err, errVersionInput)
371+
}
372+
versionOut += "." + strconv.Itoa(version2)
373+
} else {
374+
versionOut += ".x"
370375
}
371-
versionOut += "." + strconv.Itoa(version2)
372376
}
373377
return &versionOut, nil
374378
}

pkg/controller/cache/replicationgroup/managed_test.go

+52-2
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ import (
3737
)
3838

3939
const (
40-
name = "coolGroup"
41-
engineVersionToTest = "5.0.2"
40+
name = "coolGroup"
41+
engineVersionToTest = "5.0.2"
42+
alternateEngineVersionToTest = "6.x"
4243
)
4344

4445
var (
4546
cacheNodeType = "n1.super.cool"
4647
autoFailoverEnabled = true
4748
cacheParameterGroupName = "coolParamGroup"
4849
engineVersion = "5.0"
50+
alternateEngineVersion = "6.x"
4951
port = 6379
5052
host = "172.16.0.1"
5153
maintenanceWindow = "tomorrow"
@@ -789,6 +791,54 @@ func TestUpdate(t *testing.T) {
789791
),
790792
returnsErr: false,
791793
},
794+
{
795+
name: "IncreaseReplicationsAndCheckBehaviourVersionx",
796+
e: &external{client: &fake.MockClient{
797+
MockDescribeReplicationGroups: func(ctx context.Context, _ *elasticache.DescribeReplicationGroupsInput, opts []func(*elasticache.Options)) (*elasticache.DescribeReplicationGroupsOutput, error) {
798+
return &elasticache.DescribeReplicationGroupsOutput{
799+
ReplicationGroups: []types.ReplicationGroup{{
800+
Status: aws.String(v1beta1.StatusAvailable),
801+
MemberClusters: cacheClusters,
802+
AutomaticFailover: types.AutomaticFailoverStatusEnabled,
803+
CacheNodeType: aws.String(cacheNodeType),
804+
SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)),
805+
SnapshotWindow: aws.String(snapshotWindow),
806+
ClusterEnabled: aws.Bool(true),
807+
ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)},
808+
}},
809+
}, nil
810+
},
811+
MockDescribeCacheClusters: func(ctx context.Context, _ *elasticache.DescribeCacheClustersInput, opts []func(*elasticache.Options)) (*elasticache.DescribeCacheClustersOutput, error) {
812+
return &elasticache.DescribeCacheClustersOutput{
813+
CacheClusters: []types.CacheCluster{
814+
{EngineVersion: aws.String(engineVersion)},
815+
{EngineVersion: aws.String(engineVersion)},
816+
{EngineVersion: aws.String(engineVersion)},
817+
},
818+
}, nil
819+
},
820+
MockIncreaseReplicaCount: func(ctx context.Context, _ *elasticache.IncreaseReplicaCountInput, opts []func(*elasticache.Options)) (*elasticache.IncreaseReplicaCountOutput, error) {
821+
return &elasticache.IncreaseReplicaCountOutput{}, nil
822+
},
823+
}},
824+
r: replicationGroup(
825+
withEngineVersion(alternateEngineVersionToTest),
826+
withReplicationGroupID(name),
827+
withProviderStatus(v1beta1.StatusAvailable),
828+
withConditions(xpv1.Available()),
829+
withMemberClusters(cacheClusters),
830+
withNumCacheClusters(4),
831+
),
832+
want: replicationGroup(
833+
withEngineVersion(alternateEngineVersion),
834+
withReplicationGroupID(name),
835+
withProviderStatus(v1beta1.StatusAvailable),
836+
withConditions(xpv1.Available()),
837+
withMemberClusters(cacheClusters),
838+
withNumCacheClusters(4),
839+
),
840+
returnsErr: false,
841+
},
792842
}
793843

794844
for _, tc := range cases {

0 commit comments

Comments
 (0)