Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix horizontal scaling for ReplicationGroups #136

Conversation

gfrey
Copy link
Contributor

@gfrey gfrey commented Jun 13, 2024

This will set the value for the number of node groups of a ReplicationGroup to the value given in the Spec, thereby enabling horizontal scaling.

Fixes aws-controllers-k8s/community#2080.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and nmvk June 13, 2024 09:33
@ack-prow ack-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 13, 2024
Copy link

ack-prow bot commented Jun 13, 2024

Hi @gfrey. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gfrey gfrey changed the title Fix vertical scaling for ReplicationGroups Fix horizontal scaling for ReplicationGroups Jun 13, 2024
This will set the value for the number of node groups of a
ReplicationGroup to the value given in the Spec, thereby enabling
horizontal scaling.

Fixes aws-controllers-k8s/community#2080.
@gfrey gfrey force-pushed the fix/2080/replication_group_horizontal_scaling branch from d1b2b99 to 43a3c54 Compare June 14, 2024 05:57
@gfrey
Copy link
Contributor Author

gfrey commented Jun 14, 2024

I forced push an updated commit message (I had vertical and horizontal scaling mixed up).

@gfrey gfrey marked this pull request as draft June 14, 2024 14:11
@ack-prow ack-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 14, 2024
@gfrey
Copy link
Contributor Author

gfrey commented Jun 14, 2024

Converted to a draft, as I can't properly verify the fix. Even without it the test_rg_scale_horizontally test works just fine. When I noticed the issue, I had updated the NumNodeGroup in the spec, but that didn't trigger any changes to the replication group. Only when I also updated the instance type, the horizontal scaling was also picked up.

Let me first try to recreate the issue.

@gfrey
Copy link
Contributor Author

gfrey commented Jun 17, 2024

I've tested this with a resource like the following:

---
apiVersion: "elasticache.services.k8s.aws/v1alpha1"
kind: ReplicationGroup
metadata:
  name: my-test
  namespace: default
spec:
  description: CloudCache Redis my-test
  automaticFailoverEnabled: true
  engine: Redis
  engineVersion: "7.0"
  cacheNodeType: cache.t4g.micro
  replicasPerNodeGroup: 1
  port: 6379
  multiAZEnabled: true
  replicationGroupID: my-test-cloudcache
  cacheParameterGroupName: default.redis7.cluster.on

  numNodeGroups: 1

  atRestEncryptionEnabled: true
  transitEncryptionEnabled: true
  preferredMaintenanceWindow: "sun:22:00-sun:23:00"
  1. Using the controller from the main branch, a change to numNodeGroups doesn't start updating the resource. Subsequent updates to other fields (say the instance type) will also trigger the horizontal scaling.
  2. Using the controller from this PR, the change will be detected and trigger the expected update.

I'm not sure, why the k8s.patch_custom_resource call from test_rg_scale_horizontally triggers an update.

@gfrey gfrey marked this pull request as ready for review June 17, 2024 13:18
@ack-prow ack-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2024
@a-hilaly
Copy link
Member

/ok-to-test

@ack-prow ack-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 17, 2024
Comment on lines +93 to +95
if respRG.NodeGroups != nil && ko.Spec.NumNodeGroups != nil {
*ko.Spec.NumNodeGroups = int64(len(respRG.NodeGroups))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@a-hilaly
Copy link
Member

a-hilaly commented Jul 1, 2024

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2024
Copy link

ack-prow bot commented Jul 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, gfrey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the approved label Jul 1, 2024
@ack-prow ack-prow bot merged commit a63890e into aws-controllers-k8s:main Jul 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ElastiCache ReplicationGroup support for changes to numNodeGroups parameter
2 participants