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

Add OmitUnchangedField config for selective inclusion of changed CRD fields in update requests. #406

Merged

Conversation

a-hilaly
Copy link
Member

@a-hilaly a-hilaly commented Feb 8, 2023

Issue: aws-controllers-k8s/community#1598

This patch adds a new generator configuration
update_operation.omit_unchanged_fields that instructs the code
generator to generate code that only includes fields in update requests
if their values have actually changed. This is accomplished by using
delta.DifferentAt before setting any field in the newUpdateRequest
function.

This change will improve the reliability of the generated code by
preventing the controller from trying to update unnecessary fields.

Signed-off-by: Amine Hilaly hilalyamine@gmail.com

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 jljaco and RedbackThomson February 8, 2023 14:14
@ack-prow ack-prow bot added the approved label Feb 8, 2023
Comment on lines 34 to 39
//
// .Authors ([]*string)
// .ImageData
// .Location (*string)
// .Tag (*string)
// .Name (*string)
Copy link
Member Author

Choose a reason for hiding this comment

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

Weird from my new gofmt (using go1.20)

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, no worries. we should probably do a single style-only commit that updates gofmt for this repository (and runtime)

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, no worries. we should probably do a single style-only commit that updates gofmt for this repository (and runtime)

@a-hilaly et voila:

@a-hilaly a-hilaly force-pushed the update/omit-unchanged-fields branch from 2c7f73d to ea71010 Compare February 15, 2023 14:35
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

I like this. One little suggestion inline but I approve of this :)

templates/pkg/resource/sdk_update.go.tpl Outdated Show resolved Hide resolved
Copy link
Contributor

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

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

Just wanted to +1 Jay's comment, otherwise I think it's ready to ship!

@a-hilaly a-hilaly force-pushed the update/omit-unchanged-fields branch from ea71010 to c0dc480 Compare February 16, 2023 18:47
fields in update requests.

This patch adds a new generator configuration
`update_operation.omit_unchanged_fields` that instructs the code
generator to generate cvode that only include fields in update reuqests
if their values have actually changed. This is accomplished by using
`delta.DifferentAt` before setting any field in `newUpdateRequest`
function.

This change will improve the reliability of the generated code by
preventing the controller from trying to update unecessary fields.

Signed-off-by: Amine Hilaly <hilalyamine@gmail.com>
@a-hilaly a-hilaly force-pushed the update/omit-unchanged-fields branch from c0dc480 to e248468 Compare February 16, 2023 19:26
@a-hilaly
Copy link
Member Author

/test all

@jljaco
Copy link
Contributor

jljaco commented Feb 16, 2023

/retest

4 similar comments
@jljaco
Copy link
Contributor

jljaco commented Feb 16, 2023

/retest

@jljaco
Copy link
Contributor

jljaco commented Feb 16, 2023

/retest

@jljaco
Copy link
Contributor

jljaco commented Feb 17, 2023

/retest

@jljaco
Copy link
Contributor

jljaco commented Feb 17, 2023

/retest

@ack-prow
Copy link

ack-prow bot commented Feb 17, 2023

@a-hilaly: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ec2-controller-test e248468 link true /test ec2-controller-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@a-hilaly
Copy link
Member Author

Addressed the comment anyone can manually ship this? @RedbackThomson @jljaco

@RedbackThomson
Copy link
Contributor

Ready to ship. Thank you
/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2023
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

This patch is not introducing the failure in the ec2 test:

 Error: template: /home/prow/go/src/github.com/aws-controllers-k8s/code-generator/templates/pkg/resource/references.go.tpl:120:3: executing "/home/prow/go/src/github.com/aws-controllers-k8s/code-generator/templates/pkg/resource/references.go.tpl" at <GoCodeResolveReference $field "ko" 1>: error calling GoCodeResolveReference: references within lists inside lists aren't supported. crd: "RouteTable", path: "Routes.GatewayID"
make: *** [Makefile:41: build-controller] Error 2 

I recommend we force-merge this patch and fix the nested list reference struct issue separately.

@ack-prow
Copy link

ack-prow bot commented Feb 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, jaypipes, RedbackThomson

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:
  • OWNERS [A-Hilaly,RedbackThomson]

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

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants