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

Notebooks 2.0 // Controller // Replace reflect.DeepEqual with equality.Semantic.DeepEqual #69

Open
thesuperzapper opened this issue Oct 28, 2024 · 3 comments
Assignees
Labels
area/controller area - related to controller components kind/enhancement kind - new features or changes project/notebooks-v2 project - kubeflow notebooks v2

Comments

@thesuperzapper
Copy link
Member

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:

  1. a nil map is not equal to an empty map
  2. a nil slice is not equal to an empty slice
  3. resource requests need to be carefully compared (as they can be specified in a lot of forms)
  4. 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

  1. replace all instances of reflect.DeepEqual with equality.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.
  2. remove any special methods we are using to compare/mutate the objects before applying the equality check
@github-project-automation github-project-automation bot moved this to Needs Triage in Kubeflow Notebooks Oct 28, 2024
@thesuperzapper thesuperzapper added this to the v2.0.0-alpha.0 milestone Oct 28, 2024
@thesuperzapper thesuperzapper added kind/enhancement kind - new features or changes area/controller area - related to controller components project/notebooks-v2 project - kubeflow notebooks v2 labels Oct 28, 2024
@Adembc
Copy link

Adembc commented Oct 29, 2024

Good catch! Really interesting stuff.

@Adembc
Copy link

Adembc commented Nov 11, 2024

Could you please assign this issue to me?
@thesuperzapper

@ederign
Copy link
Member

ederign commented Nov 15, 2024

/assign @Adembc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/controller area - related to controller components kind/enhancement kind - new features or changes project/notebooks-v2 project - kubeflow notebooks v2
Projects
Status: Needs Triage
Development

No branches or pull requests

3 participants