Skip to content

Commit

Permalink
Merge pull request #1405 from sparebank1utvikling/NumCacheClusters
Browse files Browse the repository at this point in the history
replicationgroup: Allow unmanaged NumCacheClusters
  • Loading branch information
haarchri authored Aug 8, 2022
2 parents cda22ce + 15d575a commit c5ec106
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/clients/elasticache/elasticache.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func DiffTags(rgtags []v1beta1.Tag, tags []elasticachetypes.Tag) (add map[string
// ReplicationGroupNumCacheClustersNeedsUpdate determines if the number of Cache Clusters
// in a replication group needs to be updated
func ReplicationGroupNumCacheClustersNeedsUpdate(kube v1beta1.ReplicationGroupParameters, ccList []elasticachetypes.CacheCluster) bool {
return aws.ToInt(kube.NumCacheClusters) != len(ccList)
return kube.NumCacheClusters != nil && aws.ToInt(kube.NumCacheClusters) != len(ccList)
}

// GenerateObservation produces a ReplicationGroupObservation object out of
Expand Down
2 changes: 1 addition & 1 deletion pkg/clients/elasticache/elasticache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ func TestReplicationGroupNumCacheClustersNeedsUpdate(t *testing.T) {
{EngineVersion: aws.String(engineVersion)},
},
},
want: want{res: true},
want: want{res: false},
},
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/cache/managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
errModifyReplicationGroup = "cannot modify ElastiCache replication group"
errDeleteReplicationGroup = "cannot delete ElastiCache replication group"
errModifyReplicationGroupSC = "cannot modify ElastiCache replication group shard configuration"
errModifyReplicationGroupCC = "cannot modify ElastiCache replication group num cache clusters"
errListReplicationGroupTags = "cannot list ElastiCache replication group tags"
errUpdateReplicationGroupTags = "cannot update ElastiCache replication group tags"
errReplicationGroupCacheClusterMinimum = "at least 1 replica is required"
Expand Down Expand Up @@ -238,7 +239,7 @@ func (e *external) Update(ctx context.Context, mg resource.Managed) (managed.Ext
if elasticache.ReplicationGroupNumCacheClustersNeedsUpdate(cr.Spec.ForProvider, ccList) {
err := e.updateReplicationGroupNumCacheClusters(ctx, meta.GetExternalName(cr), len(ccList), aws.ToInt(cr.Spec.ForProvider.NumCacheClusters))
if err != nil {
return managed.ExternalUpdate{}, awsclient.Wrap(err, errModifyReplicationGroup)
return managed.ExternalUpdate{}, awsclient.Wrap(err, errModifyReplicationGroupCC)
}
return managed.ExternalUpdate{}, nil
}
Expand Down

0 comments on commit c5ec106

Please sign in to comment.