-
Notifications
You must be signed in to change notification settings - Fork 770
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
Feature/revision index #1733
base: master
Are you sure you want to change the base?
Feature/revision index #1733
Conversation
09f5315
to
0f20137
Compare
err := rh.List(context.TODO(), &revisions, &client.ListOptions{Namespace: parent.GetNamespace(), LabelSelector: selector}) | ||
if err != nil { | ||
return nil, err | ||
opts := &client.ListOptions{ |
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.
consider add DisableDeepCopy option
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.
When use DisableDeepCopy, kruise will panic in e2e because some update codes in cloneset VCTHashEqual handler.
We should fix it. @shiyan2016
pkg/controller/cloneset/cloneset_controller.go:453
lastEqualRevision := equalRevisions[equalCount-1]
if !VCTHashEqual(lastEqualRevision, updateRevision) {
klog.InfoS("Revision vct hash will be updated", "revisionName", lastEqualRevision.Name, "lastRevisionVCTHash", lastEqualRevision.Annotations[volumeclaimtemplate.HashAnnotation], "updateRevisionVCTHash", updateRevision.Annotations[volumeclaimtemplate.HashAnnotation])
lastEqualRevision.Annotations[volumeclaimtemplate.HashAnnotation] = updateRevision.Annotations[volumeclaimtemplate.HashAnnotation]
}
// if the equivalent revision is not immediately prior we will roll back by incrementing the
// Revision of the equivalent revision
updateRevision, err = r.controllerHistory.UpdateControllerRevision(equalRevisions[equalCount-1], updateRevision.Revision)
plz fix the ut |
29fc5b4
to
d5e1156
Compare
Signed-off-by: shiyan2016 <[email protected]>
d5e1156
to
fc894ef
Compare
@@ -137,6 +139,7 @@ func init() { | |||
utilruntime.Must(appsv1.AddToScheme(scheme)) | |||
utilruntime.Must(appsv1alpha1.AddToScheme(scheme)) | |||
utilruntime.Must(corev1.AddToScheme(scheme)) | |||
utilruntime.Must(apps.AddToScheme(scheme)) |
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.
there is no need to add unversioned scheme here, L139 already do the job
@@ -69,7 +71,13 @@ func TestRevisionHistory(t *testing.T) { | |||
t.Fatalf("Failed to new controller revision: %v", err) | |||
} | |||
|
|||
fakeClient := fake.NewClientBuilder().Build() | |||
fakeClient := fake.NewClientBuilder().WithIndex(&apps.ControllerRevision{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { | |||
var owners []string |
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.
There are so many errors in other uts and can be fixed by using client with index.
I think we should wrap this code with a customized function and replace fake.NewClientBuilder()
.
err := rh.List(context.TODO(), &revisions, &client.ListOptions{Namespace: parent.GetNamespace(), LabelSelector: selector}) | ||
if err != nil { | ||
return nil, err | ||
opts := &client.ListOptions{ |
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.
When use DisableDeepCopy, kruise will panic in e2e because some update codes in cloneset VCTHashEqual handler.
We should fix it. @shiyan2016
pkg/controller/cloneset/cloneset_controller.go:453
lastEqualRevision := equalRevisions[equalCount-1]
if !VCTHashEqual(lastEqualRevision, updateRevision) {
klog.InfoS("Revision vct hash will be updated", "revisionName", lastEqualRevision.Name, "lastRevisionVCTHash", lastEqualRevision.Annotations[volumeclaimtemplate.HashAnnotation], "updateRevisionVCTHash", updateRevision.Annotations[volumeclaimtemplate.HashAnnotation])
lastEqualRevision.Annotations[volumeclaimtemplate.HashAnnotation] = updateRevision.Annotations[volumeclaimtemplate.HashAnnotation]
}
// if the equivalent revision is not immediately prior we will roll back by incrementing the
// Revision of the equivalent revision
updateRevision, err = r.controllerHistory.UpdateControllerRevision(equalRevisions[equalCount-1], updateRevision.Revision)
@@ -219,6 +229,13 @@ func testUpdateWhenSidecarSetPaused(t *testing.T, sidecarSetInput *appsv1alpha1. | |||
|
|||
fakeClient := fake.NewClientBuilder().WithScheme(scheme). | |||
WithObjects(sidecarSetInput, podInput). | |||
WithIndex(&apps.ControllerRevision{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { |
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.
use appsv1.ControllerRevision{}
Ⅰ. Describe what this PR does
add revision fieldindex to optimize list revisions operation
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how to verify it
Ⅳ. Special notes for reviews