consistencydetector

package
v0.31.0-alpha.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDataConsistency

func CheckDataConsistency[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn ListFunc[T], listOptions metav1.ListOptions, retrieveItemsFn RetrieveItemsFunc[U])

CheckDataConsistency exists solely for testing purposes. we cannot use checkWatchListDataConsistencyIfRequested because it is guarded by an environmental variable. we cannot manipulate the environmental variable because it will affect other tests in this package.

func CheckListFromCacheDataConsistencyIfRequested

func CheckListFromCacheDataConsistencyIfRequested[T runtime.Object](ctx context.Context, identity string, listItemsFn ListFunc[T], optionsUsedToReceiveList metav1.ListOptions, receivedList runtime.Object)

CheckListFromCacheDataConsistencyIfRequested performs a data consistency check only when the KUBE_LIST_FROM_CACHE_INCONSISTENCY_DETECTOR environment variable was set during a binary startup for requests that have a high chance of being served from the watch-cache.

The consistency check is meant to be enforced only in the CI, not in production. The check ensures that data retrieved by a list api call from the watch-cache is exactly the same as data received by the list api call from etcd.

Note that this function will panic when data inconsistency is detected. This is intentional because we want to catch it in the CI.

Note that this function doesn't examine the ListOptions to determine if the original request has hit the cache because it would be challenging to maintain consistency with the server-side implementation. For simplicity, we assume that the first request retrieved data from the cache (even though this might not be true for some requests) and issue the second call to get data from etcd for comparison.

func CheckWatchListFromCacheDataConsistencyIfRequested

func CheckWatchListFromCacheDataConsistencyIfRequested[T runtime.Object](ctx context.Context, identity string, listItemsFn ListFunc[T], optionsUsedToReceiveList metav1.ListOptions, receivedList runtime.Object)

CheckWatchListFromCacheDataConsistencyIfRequested performs a data consistency check only when the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup.

The consistency check is meant to be enforced only in the CI, not in production. The check ensures that data retrieved by the watch-list api call is exactly the same as data received by the standard list api call against etcd.

Note that this function will panic when data inconsistency is detected. This is intentional because we want to catch it in the CI.

func IsDataConsistencyDetectionForWatchListEnabled

func IsDataConsistencyDetectionForWatchListEnabled() bool

IsDataConsistencyDetectionForWatchListEnabled returns true when the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup.

Types

type ListFunc

type ListFunc[T runtime.Object] func(ctx context.Context, options metav1.ListOptions) (T, error)

type RetrieveItemsFunc

type RetrieveItemsFunc[U any] func() []U

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL