Merge pull request #120304 from p0lyn0mial/upstream-storage-options-progress-notification

storage: document ProgressNotify from storage.ListOptions

Kubernetes-commit: a42f4f61c2c46553bfe338eefe9e81818c7360b4
This commit is contained in:
Kubernetes Publisher 2023-09-01 07:54:51 -07:00
commit 9998872cea
6 changed files with 35 additions and 11 deletions

8
go.mod
View File

@ -41,9 +41,9 @@ require (
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/square/go-jose.v2 v2.6.0
k8s.io/api v0.0.0-20230901043045-d68a18351c00
k8s.io/api v0.0.0-20230901043046-faec07c7cc89
k8s.io/apimachinery v0.0.0-20230901041540-0d057e543013
k8s.io/client-go v0.0.0-20230901044724-5e5ba6b91d64
k8s.io/client-go v0.0.0-20230901180031-5e052e483509
k8s.io/component-base v0.0.0-20230901051635-6a97c85314ee
k8s.io/klog/v2 v2.100.1
k8s.io/kms v0.0.0-20230901053518-2b0cdaf495d2
@ -126,9 +126,9 @@ require (
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20230901043045-d68a18351c00
k8s.io/api => k8s.io/api v0.0.0-20230901043046-faec07c7cc89
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230901041540-0d057e543013
k8s.io/client-go => k8s.io/client-go v0.0.0-20230901044724-5e5ba6b91d64
k8s.io/client-go => k8s.io/client-go v0.0.0-20230901180031-5e052e483509
k8s.io/component-base => k8s.io/component-base v0.0.0-20230901051635-6a97c85314ee
k8s.io/kms => k8s.io/kms v0.0.0-20230901053518-2b0cdaf495d2
)

8
go.sum
View File

@ -670,12 +670,12 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20230901043045-d68a18351c00 h1:plDl2FaMrSOtZgQQfiE4PwlUH1sTuQ92EY7aMnxRciI=
k8s.io/api v0.0.0-20230901043045-d68a18351c00/go.mod h1:qunKCI5HG1/XacwNcIwUHAFWPw6hFmIP5fb13hHJARM=
k8s.io/api v0.0.0-20230901043046-faec07c7cc89 h1:qgk2nx6RBhIWmGYpmsbP9nuOFK/ZHpzKS2Bk13dYzqU=
k8s.io/api v0.0.0-20230901043046-faec07c7cc89/go.mod h1:qunKCI5HG1/XacwNcIwUHAFWPw6hFmIP5fb13hHJARM=
k8s.io/apimachinery v0.0.0-20230901041540-0d057e543013 h1:SWrddEv3aWWseUfiT42ziJUc8Gck/2Iqltz0Z+ctTB8=
k8s.io/apimachinery v0.0.0-20230901041540-0d057e543013/go.mod h1:4XSLsQ98qjSQA9IF1M+KnXoc+E7kiualOL0cx3GFYZI=
k8s.io/client-go v0.0.0-20230901044724-5e5ba6b91d64 h1:33kcwhVZBpBQ62AGlcCwolDgA8wOGuVLfhHBqh8gJ1E=
k8s.io/client-go v0.0.0-20230901044724-5e5ba6b91d64/go.mod h1:G0tP68oMXxgJnZv7d81fi115Hw9QymSbdptKK8BuyAc=
k8s.io/client-go v0.0.0-20230901180031-5e052e483509 h1:8ImDNx9hJM97LVDvxletFrniXqar1M9YFQqLWid1N/A=
k8s.io/client-go v0.0.0-20230901180031-5e052e483509/go.mod h1:JzQk2oylP9hExOxB75uIVBuewuTkXrbQW+wBlineOZg=
k8s.io/component-base v0.0.0-20230901051635-6a97c85314ee h1:Anwc25j0e3xg4JVrZ5eYm38LYFPWENftQc17unJmRn8=
k8s.io/component-base v0.0.0-20230901051635-6a97c85314ee/go.mod h1:yBM3yqVHGaf3rugDRYf5C5JHw/gT2E3MCfyCEErkVVQ=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=

View File

@ -312,7 +312,7 @@ func TestNamespaceScopedWatch(t *testing.T) {
func TestWatchDispatchBookmarkEvents(t *testing.T) {
ctx, cacher, terminate := testSetup(t)
t.Cleanup(terminate)
storagetesting.RunTestWatchDispatchBookmarkEvents(ctx, t, cacher)
storagetesting.RunTestWatchDispatchBookmarkEvents(ctx, t, cacher, true)
}
func TestWatchBookmarksWithCorrectResourceVersion(t *testing.T) {

View File

@ -104,6 +104,17 @@ func TestProgressNotify(t *testing.T) {
storagetesting.RunOptionalTestProgressNotify(ctx, t, store)
}
// TestWatchDispatchBookmarkEvents makes sure that
// setting allowWatchBookmarks query param against
// etcd implementation doesn't have any effect.
func TestWatchDispatchBookmarkEvents(t *testing.T) {
clusterConfig := testserver.NewTestConfig(t)
clusterConfig.ExperimentalWatchProgressNotifyInterval = time.Second
ctx, store, _ := testSetup(t, withClientConfig(clusterConfig))
storagetesting.RunTestWatchDispatchBookmarkEvents(ctx, t, store, false)
}
func TestSendInitialEventsBackwardCompatibility(t *testing.T) {
ctx, store, _ := testSetup(t)
storagetesting.RunSendInitialEventsBackwardCompatibility(ctx, t, store)

View File

@ -282,6 +282,19 @@ type ListOptions struct {
Recursive bool
// ProgressNotify determines whether storage-originated bookmark (progress notify) events should
// be delivered to the users. The option is ignored for non-watch requests.
//
// Firstly, note that this field is different from the Predicate.AllowWatchBookmarks field.
// Secondly, this field is intended for internal clients only such as the watch cache.
//
// This means that external clients do not have the ability to set this field directly.
// For example by setting the allowWatchBookmarks query parameter.
//
// The motivation for this approach is the fact that the frequency
// of bookmark events from a storage like etcd might be very high.
// As the number of watch requests increases, the server load would also increase.
//
// Furthermore, the server is not obligated to provide bookmark events at all,
// as described in https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/956-watch-bookmark#proposal
ProgressNotify bool
// SendInitialEvents, when set together with Watch option,
// begin the watch stream with synthetic init events to build the

View File

@ -1042,7 +1042,7 @@ func RunTestNamespaceScopedWatch(ctx context.Context, t *testing.T, store storag
// TODO(#109831): ProgressNotify feature is effectively implementing the same
//
// functionality, so we should refactor this functionality to share the same input.
func RunTestWatchDispatchBookmarkEvents(ctx context.Context, t *testing.T, store storage.Interface) {
func RunTestWatchDispatchBookmarkEvents(ctx context.Context, t *testing.T, store storage.Interface, expectedWatchBookmarks bool) {
key, storedObj := testPropagateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "test-ns"}})
startRV := storedObj.ResourceVersion
@ -1061,7 +1061,7 @@ func RunTestWatchDispatchBookmarkEvents(ctx context.Context, t *testing.T, store
{
name: "allowWatchBookmarks=true",
timeout: 3 * time.Second,
expected: true,
expected: expectedWatchBookmarks,
allowWatchBookmarks: true,
},
}