mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-21 12:48:30 +00:00
client-go/reflector: use consistencydetector.IsDataConsistencyDetectionForWatchListEnabled
Kubernetes-commit: f6c68908ba37dbb7af602b8f88b5f395025d2384
This commit is contained in:
parent
14559c0fec
commit
b681e77bec
@ -18,20 +18,12 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
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/client-go/util/consistencydetector"
|
"k8s.io/client-go/util/consistencydetector"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dataConsistencyDetectionForWatchListEnabled = false
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
dataConsistencyDetectionForWatchListEnabled, _ = strconv.ParseBool(os.Getenv("KUBE_WATCHLIST_INCONSISTENCY_DETECTOR"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// checkWatchListDataConsistencyIfRequested performs a data consistency check only when
|
// checkWatchListDataConsistencyIfRequested performs a data consistency check only when
|
||||||
// the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup.
|
// the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup.
|
||||||
//
|
//
|
||||||
@ -42,7 +34,7 @@ func init() {
|
|||||||
// Note that this function will panic when data inconsistency is detected.
|
// Note that this function will panic when data inconsistency is detected.
|
||||||
// This is intentional because we want to catch it in the CI.
|
// This is intentional because we want to catch it in the CI.
|
||||||
func checkWatchListDataConsistencyIfRequested[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn consistencydetector.ListFunc[T], retrieveItemsFn consistencydetector.RetrieveItemsFunc[U]) {
|
func checkWatchListDataConsistencyIfRequested[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn consistencydetector.ListFunc[T], retrieveItemsFn consistencydetector.RetrieveItemsFunc[U]) {
|
||||||
if !dataConsistencyDetectionForWatchListEnabled {
|
if !consistencydetector.IsDataConsistencyDetectionForWatchListEnabled() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// for informers we pass an empty ListOptions because
|
// for informers we pass an empty ListOptions because
|
||||||
|
Loading…
Reference in New Issue
Block a user