-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
area/controllerarea - related to controller componentsarea - related to controller componentsarea/v2area - version - kubeflow notebooks v2area - version - kubeflow notebooks v2kind/enhancementkind - new features or changeskind - new features or changes
Milestone
Description
What's the problem?
We currently use reflect.DeepEqual
to do a lot of comparisons in the Notebooks 2.0 controller.
As a result of this, we have to take special care when comparing Kubernetes API objects for a number of reasons:
- a
nil
map is not equal to an empty map - a
nil
slice is not equal to an empty slice - resource requests need to be carefully compared (as they can be specified in a lot of forms)
- time quantities need to be carefully compared (as they can be specified in a lot of forms)
Therefore, we need to use helper method like NormalizePodConfigSpec
and other cases to handle this complexity.
What am I proposing?
We can replace this complexity by using Kubernetes built in API object semantic comparison:
import "k8s.io/apimachinery/pkg/api/equality"
...
if equality.Semantic.DeepEqual(object1, object1) {
return false, nil
}
Next Steps
- replace all instances of
reflect.DeepEqual
withequality.Semantic.DeepEqual
- NOTE: this should ONLY be changed for comparisons between Kubernetes API objects, or parts of them, not other things we might be comparing.
- remove any special methods we are using to compare/mutate the objects before applying the equality check
Metadata
Metadata
Assignees
Labels
area/controllerarea - related to controller componentsarea - related to controller componentsarea/v2area - version - kubeflow notebooks v2area - version - kubeflow notebooks v2kind/enhancementkind - new features or changeskind - new features or changes
Type
Projects
Status
Needs Triage