-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
improve discoveryHelper.Refresh() in restore #7069
Conversation
Signed-off-by: lou <alex1988@outlook.com>
Codecov ReportAttention:
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. |
Signed-off-by: lou <alex1988@outlook.com>
pkg/restore/restore.go
Outdated
// 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 { |
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.
How about refreshing the discovery helper no matter whether new items are created or not? This is much easier.
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.
yes, it is easier, but if no crds are created, refresh is meaningless, and it takes time (~9s in my env)
pkg/restore/restore.go
Outdated
@@ -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() |
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.
Please double-check whether this covers CRD updating case
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.
Let's put the returning items into a structure
Signed-off-by: lou <alex1988@outlook.com>
Please add a summary of your change
discoveryHelper.Refresh()
was called after every crd restore, this logic has two issues: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:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.