Skip to content

Conversation

@Arvindthiru
Copy link
Contributor

@Arvindthiru Arvindthiru commented Feb 2, 2023

Description of your changes

The changes in the PR validates the annotation size of the last modified config annotation on the manifest and if it crosses the annotation size threshold it removes the annotation and creates/updates the object on the cluster using server side apply instead of using three way merge.

This ensures that when large objects are propagated we don't fail to apply the object

Fixes #295

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Unit tests

Special notes for your reviewer

Redis guide: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/run-scalable-and-resilient-redis-with-kubernetes-and-azure/ba-p/3247956

Propagated redis helm secret to member cluster

Screenshot 2023-02-05 at 5 09 36 PM
Screenshot 2023-02-05 at 5 09 49 PM

https://blog.atomist.com/kubernetes-apply-replace-patch/

https://stackoverflow.com/questions/28459418/use-of-put-vs-patch-methods-in-rest-api-real-life-scenarios/39338329#39338329

@Arvindthiru Arvindthiru marked this pull request as ready for review February 8, 2023 01:04
Copy link
Contributor

@zhiying-lin zhiying-lin left a comment

Choose a reason for hiding this comment

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

  • please add e2e tests to cover create/update the large secret.
  • please update your PR description to indicate how/why your PR fixes the bug.

@Arvindthiru Arvindthiru force-pushed the AnnotationSizeLimit branch from 17b3b12 to 956f1b4 Compare April 24, 2023 21:46
@Arvindthiru
Copy link
Contributor Author

Putting the PR as draft to work on E2E

@Arvindthiru Arvindthiru marked this pull request as draft May 9, 2023 16:34
@Arvindthiru Arvindthiru force-pushed the AnnotationSizeLimit branch from 59176d9 to bd6e3c9 Compare May 17, 2023 01:02
@Arvindthiru Arvindthiru marked this pull request as ready for review May 17, 2023 01:05
@Arvindthiru
Copy link
Contributor Author

Arvindthiru commented May 17, 2023

Instead of removing the last applied config annotation I'm currently setting the annotation to "". This is done because of the scenario described below.

  • Create an object within the annotation limit, we get an object with spec-hash and last modified config annotations on it
  • Then when we update the object to be large, we use server side apply to update the object but since it's server side apply even if we remove the annotation from the object in the controller it sees the pre-existing last applied config and since the controller is not managing the field now it leaves it alone and updates other fields
  • This is not the correct behavior as we have a large object with the small object's last applied config
  • To avoid this we can update the field to be empty, and the next time around when we update the object to be small three way merge works fine as it accepts empty string as last applied config it uses an empty map

@Arvindthiru Arvindthiru force-pushed the AnnotationSizeLimit branch from bd6e3c9 to c541e01 Compare May 29, 2023 23:41
@Arvindthiru Arvindthiru force-pushed the AnnotationSizeLimit branch from 98a178b to 9999305 Compare May 31, 2023 20:50
zhiying-lin
zhiying-lin previously approved these changes Jun 1, 2023
Copy link
Contributor

@zhiying-lin zhiying-lin left a comment

Choose a reason for hiding this comment

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

one minor comment, others LGTM

@Arvindthiru Arvindthiru force-pushed the AnnotationSizeLimit branch 2 times, most recently from 9e7aecc to e0b4eee Compare June 7, 2023 17:50
@Arvindthiru Arvindthiru force-pushed the AnnotationSizeLimit branch from bd71313 to 5f8ddf0 Compare June 8, 2023 19:01
@ryanzhang-oss ryanzhang-oss merged commit 92ae7ec into Azure:main Jun 8, 2023
for testName, testCase := range tests {
t.Run(testName, func(t *testing.T) {
gotBool, gotErr := setModifiedConfigurationAnnotation(testCase.obj)
assert.Equalf(t, testCase.wantBool, gotBool, "got bool not matching for Testcase %s", testName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try to avoid the Assert libraries in the UT?

"Avoid the use of 'assert' libraries to help your tests. "
https://github.com/golang/go/wiki/TestComments#assert-libraries

weng271190436 pushed a commit that referenced this pull request Jan 6, 2026
Signed-off-by: Zhiying Lin <zhiyingl456@gmail.com>
@britaniar britaniar mentioned this pull request Jan 12, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Can't apply a resource if it's too big

5 participants