-
Notifications
You must be signed in to change notification settings - Fork 20
Handle server-side defaults #12
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
Conversation
| b *resource, | ||
| delta *ackcompare.Delta, | ||
| ) { | ||
| if a.ko.Spec.RoleARN != nil { |
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.
I'm not sure if comparing only the a parameter (a.ko.Spec.RoleARN) will work ? thinking about where someone mistakenly creates a CR without a RoleARN - i guess the changes will not be detected
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.
RoleARN is optional and user can submit CR without it. autoscaling service creates it for you if the user didn't specify it. In such cases, we don't want the controller to see it as a diff
In future, it should be set in the Spec as a server default
| b *resource, | ||
| delta *ackcompare.Delta, | ||
| ) { | ||
| if a.ko.Spec.RoleARN != nil { |
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.
RoleARN is optional and user can submit CR without it. autoscaling service creates it for you if the user didn't specify it. In such cases, we don't want the controller to see it as a diff
In future, it should be set in the Spec as a server default
| } | ||
| } | ||
|
|
||
| if a.ko.Spec.SuspendedState != nil { |
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.
As I think more about this, it seems like a better approach would be to set the server defaults for values that are null and let the comparison happen like normal(i.e. we don't add it to compare.is_ignore). This will handle the case where the user initially sets a field to true and deleted it from spec thinking it will take the default value which in this case is False.
initially
scalableDimension: "string",
serviceNamespace: "string",
suspendedState:
DynamicScalingInSuspended: true
updates the resource
scalableDimension: "string",
serviceNamespace: "string",
In this scenario, current logic will ignore comparison whereas it should report the diff
This solution only works where we know the server defaults but is a better way to handle this. What do you think?
For example, it doesn't work for Spec.RoleARN because it's a server-generated rather than default. So in future, we need to patch these type of fields to desired.
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.
Most of these resources do not support updates, so not really an issue but I agree this approach of setting defaults is a better one, fixed for suspendedState. Left RoleARN as is.
|
/ok-to-test |
surajkota
left a comment
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.
/approve
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mbaijal, surajkota 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 |
|
@mbaijal @surajkota I would recommend this PR be reverted. The code is setting these values properly: applicationautoscaling-controller/pkg/resource/scalable_target/sdk.go Lines 85 to 114 in d047c61
The root cause of the issue you are seeing has nothing to do with the Delta/Compare code and everything to do with this line in the code-generator template for manager.go: That needs to pass /cc @a-hilaly |
The ScalableTarget Resource has two fields which do not work with the existing ACK CompareResource functionality. This PR fixes this issue by adding these two fields to the ignore list for compare and then adding custom logic.
More details discussed in Issue #796
Testing