mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-14 13:33:22 +00:00
Add a replacement for cmp.Diff using json+go-difflib
Co-authored-by: Jordan Liggitt <jordan@liggitt.net> Signed-off-by: Davanum Srinivas <davanum@gmail.com> Kubernetes-commit: 03afe6471bdbf6462b7035fdaae5aa0dd9545396
This commit is contained in:
parent
62b0aba8c9
commit
f21dd69478
@ -19,14 +19,14 @@ package consistencydetector
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp" //nolint:depguard
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
@ -75,8 +75,8 @@ func CheckDataConsistency[T runtime.Object, U any](ctx context.Context, identity
|
|||||||
sort.Sort(byUID(listItems))
|
sort.Sort(byUID(listItems))
|
||||||
sort.Sort(byUID(retrievedItems))
|
sort.Sort(byUID(retrievedItems))
|
||||||
|
|
||||||
if !cmp.Equal(listItems, retrievedItems) {
|
if !reflect.DeepEqual(listItems, retrievedItems) {
|
||||||
klog.Infof("previously received data for %s is different than received by the standard list api call against etcd, diff: %v", identity, cmp.Diff(listItems, retrievedItems))
|
klog.Infof("previously received data for %s is different than received by the standard list api call against etcd, diff: %v", identity, diff.Diff(listItems, retrievedItems))
|
||||||
msg := fmt.Sprintf("data inconsistency detected for %s, panicking!", identity)
|
msg := fmt.Sprintf("data inconsistency detected for %s, panicking!", identity)
|
||||||
panic(msg)
|
panic(msg)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user