Adapt Equality package to improve equality.Semantic.DeepDerivative

217 views
Skip to first unread message

Sebastian Poxhofer

unread,
Sep 30, 2021, 7:56:53 PM9/30/21
to K8s API Machinery SIG

Hi Everyone,

I'm not sure if this is the correct SIG for this package, if that's the case where should I forward this issue?
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/third_party/forked/golang/reflect/deep_equal.go

the DeepEqual and DeepDerivative functions in the equality package are very useful for testing and the development of Operators.  As specially the later one as these have to compare locally created API objects with the current ones.

Currently it is not possible to compare the complete API object using DeepDerivate as Attributes which are implemented using custom compare functions are only compared, but they are not checked if they have still the initial values. Therefore the function will never return the correct result. https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/helper/helpers.go#L106
A example for this is time.Time of creationTimestamp attributes.

My proposal is to add an additional boolean return value to compare functions which signals if the first parameter is initialized. For the time.Time example this would be the checked with `a.Size() > 0`

A question mark here is the licensing of the golang code.

WDYT?

best regards
Sebastian

Reply all
Reply to author
Forward
0 new messages