-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support for CacheCluster resource #137
Conversation
Hi @cPu1. 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 Once the patch is verified, the new status will be reflected by the 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. |
69ddd82
to
044877e
Compare
/ok-to-test |
/test all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cPu1 thank you so much! this is great. I left few comments in-line
pkg/util/tags.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can import and reuse this for the other resource in a seperate PR
templates/hooks/cache_cluster/sdk_update_post_set_output.go.tpl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice testing
if len(parts) == 0 { | ||
return major, minor, patch | ||
} | ||
major, _ = strconv.Atoi(parts[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to handle the error here - if a user provides a completely wrong version we need to set the resource ona terminal condition stating that the engine version format is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't introduced in this PR, the function was merely moved from pkg/resource/replication_group/delta_util.go
. I did notice this but refactoring ReplicationGroup
was out of scope for this PR, and this is only used for the delta comparison so the controller will still set the resource in a terminal condition after receiving one of the configured terminal error codes from the API. If we do add this validation, we'll have to do this for both create and update.
pkg/util/engine_version.go
Outdated
patch, _ = strconv.Atoi(parts[2]) | ||
} | ||
} | ||
return major, minor, patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the patch
variable is never used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was also moved from pkg/resource/replication_group/delta_util.go
.
|
||
// if the last character of desiredEV is "x" or the major version is higher than 5, ignore patch version when comparing. | ||
// See https://github.com/aws-controllers-k8s/community/issues/1737 | ||
if dMaj > 5 || desiredEV[last:] == "x" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: why 5? what if a user provides 4.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also moved from pkg/resource/replication_group/delta_util.go
. The reason is mentioned in this PR: #115.
The purpose of this changes is to avoid the controller to compare patch versions when Redis version is >=6, since It's managed by AWS. More details aws-controllers-k8s/community#1737.
return diff.Path.Contains("Spec.PreferredAvailabilityZones") | ||
}); idx != -1 && desired.ko.Spec.PreferredAvailabilityZones != nil { | ||
if nodesDelta >= 0 { | ||
return errors.New("spec.preferredAvailabilityZones can only be changed when new nodes are being added via spec.numCacheNodes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want to make those terminal errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a terminal error. Any error returned from this function is treated as a terminal error.
oldAZsLen = len(oldValues) | ||
} | ||
if len(desiredSpec.PreferredAvailabilityZones) <= oldAZsLen { | ||
return errors.New("newly specified AZs in spec.preferredAvailabilityZones must match the number of cache nodes being added") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. It's a terminal error. Any error returned from this function is treated as a terminal error.
if nodesDelta > 0 { | ||
for i := numNodes; i > numNodes-nodesDelta; i-- { | ||
nodeID := fmt.Sprintf("%04d", i) | ||
input.CacheNodeIdsToRemove = append(input.CacheNodeIdsToRemove, &nodeID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very weird API...
044877e
to
267cea8
Compare
This changelist adds support for the ElastiCache `CacheCluster` resource. The generated code did not account for many fields in the call to `ModifyCacheCluster`, and the `DescribeCacheClusters` API does not return all fields in the spec and values for some fields are reported in the `PendingModifiedValues` field instead. To handle this, the last requested configuration for `Spec.PreferredAvailabilityZones` is stored as annotations and used to compute `NewAvailabilityZones`. Moreover, `CacheNodeIdsToRemove` is computed using `Spec.NumCacheNodes` and `PendingModifiedValues.NumCacheNodes`. Support for `Spec.LogDeliveryConfigurations` is explicitly removed and parked for later because the Describe API does not return all fields for this struct. There were many changes to other ElastiCache resources introduced in the newer SDK, so they have been removed for now and not ignored. As a result, a subsequent `make build-controller` will result in new changes. The logic for syncing tags and comparing engine versions has been refactored to promote reusability. Closes aws-controllers-k8s/community#2079. Signed-off-by: cPu1 <[email protected]>
267cea8
to
e057eb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @cPu1 ! 👍
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a-hilaly, cPu1 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 |
Issue #, if available: aws-controllers-k8s/community#2079
Description of changes:
This changelist adds support for the ElastiCache
CacheCluster
resource. The generated code did not account for many fields in the call toModifyCacheCluster
, and theDescribeCacheClusters
API does not return all fields in the spec and values for some fields are reported in thePendingModifiedValues
field instead. To handle this, the last requested configuration forSpec.PreferredAvailabilityZones
is stored as annotations and used to computeNewAvailabilityZones
. Moreover,CacheNodeIdsToRemove
is computed usingSpec.NumCacheNodes
andPendingModifiedValues.NumCacheNodes
. Support forSpec.LogDeliveryConfigurations
is explicitly removed and parked for later because the Describe API does not return all fields for this struct. There were many changes to other ElastiCache resources introduced in the newer SDK, so they have been removed for now and not ignored. As a result, a subsequentmake build-controller
will result in new changes.The logic for syncing tags and comparing engine versions has been refactored to promote reusability.
Closes aws-controllers-k8s/community#2079.
Signed-off-by: cPu1 [email protected]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.