core: dereference pointer before trying to compare with deepequal

Prior to this, we were comparing a pointer (the memory address) with a
struct. This was obviously always failing and returned false. We must
dereference the pointer to access the data contained at that memory
location.

Closes: https://github.com/rook/rook/issues/9544
Signed-off-by: Sébastien Han <seb@redhat.com>
(cherry picked from commit 5404ec13a2)
This commit is contained in:
Sébastien Han authored and mergify-bot committed 2022-01-28 10:20:40 +00:00
1 parent 4c41b5ea07
commit ce9b3ee2f2
9 files changed
+61 -12

No files matched your search

+5 -2
View File
@@ -743,8 +743,11 @@ func ConfigureExternalMetricsEndpoint(ctx *clusterd.Context, monitoringSpec ceph
}
// If endpoints are identical there is nothing to do
if reflect.DeepEqual(currentEndpoints, endpoint) {
return nil
// First check for nil pointers otherwise dereferencing a nil pointer will cause a panic
if endpoint != nil && currentEndpoints != nil {
if reflect.DeepEqual(*currentEndpoints, *endpoint) {
return nil
}
}
logger.Debugf("diff between current endpoint and newly generated one: %v \n", cmp.Diff(currentEndpoints, endpoint, cmp.Comparer(func(x, y resource.Quantity) bool { return x.Cmp(y) == 0 })))