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

fix: unnecessary notebook updates caused by compare issues #6474

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix resource compare issues
  • Loading branch information
mofanke committed May 7, 2022
commit a6c000803dcbdef4743f560483897fb577988890
16 changes: 9 additions & 7 deletions components/common/reconcilehelper/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"

"k8s.io/apimachinery/pkg/api/equality"
apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -125,7 +127,7 @@ func CopyStatefulSetFields(from, to *appsv1.StatefulSet) bool {
requireUpdate = true
}

if !reflect.DeepEqual(to.Spec.Template.Spec, from.Spec.Template.Spec) {
if !equality.Semantic.DeepDerivative(from.Spec.Template.Spec, to.Spec.Template.Spec) {
mofanke marked this conversation as resolved.
Show resolved Hide resolved
requireUpdate = true
}
to.Spec.Template.Spec = from.Spec.Template.Spec
Expand All @@ -149,12 +151,12 @@ func CopyDeploymentSetFields(from, to *appsv1.Deployment) bool {
}
to.Annotations = from.Annotations

if from.Spec.Replicas != to.Spec.Replicas {
to.Spec.Replicas = from.Spec.Replicas
if *from.Spec.Replicas != *to.Spec.Replicas {
*to.Spec.Replicas = *from.Spec.Replicas
requireUpdate = true
}

if !reflect.DeepEqual(to.Spec.Template.Spec, from.Spec.Template.Spec) {
if !equality.Semantic.DeepDerivative(from.Spec.Template.Spec, to.Spec.Template.Spec) {
requireUpdate = true
}
to.Spec.Template.Spec = from.Spec.Template.Spec
Expand Down Expand Up @@ -211,9 +213,9 @@ func CopyVirtualService(from, to *unstructured.Unstructured) bool {
return true
}

requiresUpdate := !reflect.DeepEqual(fromSpec, toSpec)
if requiresUpdate {
requireUpdate := !reflect.DeepEqual(fromSpec, toSpec)
mofanke marked this conversation as resolved.
Show resolved Hide resolved
if requireUpdate {
unstructured.SetNestedMap(to.Object, fromSpec, "spec")
}
return requiresUpdate
return requireUpdate
}
1 change: 1 addition & 0 deletions components/notebook-controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
replace github.com/kubeflow/kubeflow/components/common => ../common