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

improve discoveryHelper.Refresh() in restore #7069

Merged
merged 3 commits into from
Nov 27, 2023

Conversation

27149chen
Copy link
Contributor

@27149chen 27149chen commented Nov 7, 2023

Please add a summary of your change

discoveryHelper.Refresh() was called after every crd restore, this logic has two issues:

  1. it was called no matter the crd is restored, updated or skipped. In fact, refresh is required only when it is restored
  2. it was called after every crd restore. In fact, we just need to trigger a refresh after all crds are restored

In my env, a refresh takes 9s, and I have many crds, which causing the restore extremely slow

This pr improve it by calling refresh after all crds are restored and at least one crd are created during restore

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

Signed-off-by: lou <alex1988@outlook.com>
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (6b7ce66) 61.02% compared to head (179faf3) 61.67%.
Report is 66 commits behind head on main.

Files Patch % Lines
pkg/restore/restore.go 8.33% 10 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7069      +/-   ##
==========================================
+ Coverage   61.02%   61.67%   +0.65%     
==========================================
  Files         255      258       +3     
  Lines       27040    27659     +619     
==========================================
+ Hits        16500    17058     +558     
- Misses       9361     9405      +44     
- Partials     1179     1196      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: lou <alex1988@outlook.com>
// discovery because the restored CRDs may have created new APIs that
// didn't previously exist in the cluster, and we want to be able to
// resolve & restore instances of them in subsequent loop iterations.
if createdItems > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about refreshing the discovery helper no matter whether new items are created or not? This is much easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is easier, but if no crds are created, refresh is meaningless, and it takes time (~9s in my env)

@@ -502,7 +502,7 @@ func (ctx *restoreContext) execute() (results.Result, results.Result) {
}()

// totalItems: previously discovered items, i: iteration counter.
totalItems, processedItems, existingNamespaces := 0, 0, sets.NewString()
totalItems, processedItems, createdItems, existingNamespaces := 0, 0, 0, sets.NewString()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please double-check whether this covers CRD updating case

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put the returning items into a structure

Signed-off-by: lou <alex1988@outlook.com>
@qiuming-best qiuming-best merged commit 3fdb3ec into vmware-tanzu:main Nov 27, 2023
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants