Compare commits

...

23 Commits

Author SHA1 Message Date
Kubernetes Publisher
14fa49e736 Update dependencies to v0.23.8 tag 2022-06-16 23:58:35 +00:00
Kubernetes Publisher
a475c28713 Merge pull request #108791 from aojea/cherry-pick-108772
Cherry pick 108772

Kubernetes-commit: 05a09629ab8207a870c9178b0f5694aa92919d92
2022-03-31 09:19:36 +00:00
Kubernetes Publisher
8041ba924b Merge pull request #109159 from wojtek-t/automated-cherry-pick-of-#109137-upstream-release-1.23
Automated cherry pick of #109137 upstream release 1.23

Kubernetes-commit: 4f9c753bf05d1c353fe96eba1e06aeafc58259c8
2022-03-31 05:22:55 +00:00
Michael Bolot
0c2c708257 Addresses the issue which caused #109115
Kubernetes-commit: 814ae980477ab06f8dbe13ae4c4318110e6922f6
2022-03-29 12:35:13 -05:00
Wojciech Tyczyński
9b9e45fc6d Add test for indexer with multiple values
Kubernetes-commit: 6ba5a0bc38306b713723281d4e54d257e2936890
2022-03-30 08:52:10 +02:00
Kubernetes Publisher
ad6be0fa0b sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel Gopkg.toml */.gitattributes 2022-03-25 17:27:50 +00:00
Antonio Ojea
a26f2df3da client-go: update generated
Kubernetes-commit: f628706339c120c19d28ccfa7b1a580516be1d1a
2022-03-17 16:03:10 +01:00
Antonio Ojea
b6f49c1554 default kubernetes agent for generated clients
Set default kubernetes agent if empty

Kubernetes-commit: 3de44bd759a34f6fead9fe7254b5204684b99de8
2022-03-17 13:19:43 +01:00
Kubernetes Publisher
0f7ee7041f Merge pull request #107638 from gjkim42/cherry-pick-of-#106473-upstream-release-1.23
Update k/utils to v0.0.0-20211116205334-6203023598ed

Kubernetes-commit: 83863a0f00bc8048f2ddfcfd60eec0041056b6c0
2022-01-24 17:36:39 +00:00
Gunju Kim
42bda1a0ce Update k/utils to v0.0.0-20211116205334-6203023598ed
Kubernetes-commit: 4935e0a527e3743fc8ba768d3dc93c5f85142f10
2022-01-19 20:51:54 +09:00
Kubernetes Publisher
857d6f1290 Merge pull request #107567 from jiahuif-forks/automated-cherry-pick-of-#107565-upstream-release-1.23
Automated cherry pick of #107565: upgrade sigs.k8s.io/structured-merge-diff/v4 to v4.2.1

Kubernetes-commit: 3426f6ceaf92ad40de9f381c20d054c8fef10c03
2022-01-15 05:54:30 +00:00
Jiahui Feng
94fb0d02e4 generated: ./hack/update-vendor.sh
Kubernetes-commit: 89d8be52ef47c6a5d000a515b41f05567378a97b
2022-01-14 10:58:50 -08:00
Jiahui Feng
f739adfab1 upgrade sigs.k8s.io/structured-merge-diff/v4 to v4.2.1
Kubernetes-commit: 04f3c5793c1bc56014aeea93a3b4fefeb84b4e07
2022-01-14 10:30:23 -08:00
Kubernetes Publisher
3074be12fe Merge pull request #107334 from fasaxc/automated-cherry-pick-of-#107311-upstream-release-1.23
Automated cherry pick of #107311: client-go: Clear the ResourceVersionMatch on paged list calls

Kubernetes-commit: fa546d8cc76fe7c07c538d55efd2e6dd4ec919a5
2022-01-06 13:41:15 +00:00
Shaun Crampton
8ae6aa22f3 client-go: Clear the ResourceVersionMatch on paged list calls
API server rejects continuations with ResourceVersionMatch set.

Kubernetes-commit: cc6c36f286d59187902b0f9b6e15f80b824acc7c
2022-01-04 16:05:32 +00:00
Kubernetes Publisher
72a8f7483f Merge pull request #106835 from cpanato/go117-release-1-23
[go1.17] Update to go1.17.5 and golang.org/x/net to v0.0.0-20211209124913-491a49abca63

Kubernetes-commit: 08ad4f287316f941988fe1e1b8f425cded157048
2021-12-13 21:44:50 +00:00
Carlos Panato
d333414f84 dependencies: Update golang.org/x/net to v0.0.0-20211209124913-491a49abca63
Signed-off-by: Carlos Panato <ctadeu@gmail.com>

Kubernetes-commit: d065f7ffe77b46642f4f0802c0ad700b9d88d0ec
2021-12-10 17:39:02 +01:00
Kubernetes Publisher
c752eaaf05 Merge pull request #106782 from palnabarun/automated-cherry-pick-of-#106716-upstream-release-1.23
Automated cherry pick of #106716: bump TestHTTP1DoNotReuseRequestAfterTimeout timeout

Kubernetes-commit: a3fc39c3e3c43a32c9047d91b005bbc5c4b77229
2021-12-04 05:04:13 +00:00
Kubernetes Publisher
17bbf03b1c Merge pull request #106776 from SergeyKanzhelev/grpcFieldNameCharryPick
Grpc field name cherry pick: 1.23

Kubernetes-commit: 93fb324dce69cdb2b5982058b167a45b2a51979d
2021-12-03 09:20:23 +00:00
Sergey Kanzhelev
1d1035d4c3 regenerated files
Kubernetes-commit: 8e4834f3bcdfff805aa1a4dc422acffa779d9cbd
2021-12-02 04:44:46 +00:00
Kubernetes Publisher
f3c25ef2e8 Merge pull request #106661 from liggitt/automated-cherry-pick-of-#106660-upstream-release-1.23
Automated cherry pick of #106660: Revert sigs.k8s.io/structured-merge-diff/v4 to v4.1.2

Kubernetes-commit: 724289524084f6edbbe53e31d2c6e636343fdebb
2021-12-03 09:20:21 +00:00
Antonio Ojea
0d944767ec bump TestHTTP1DoNotReuseRequestAfterTimeout timeout
the test TestHTTP1DoNotReuseRequestAfterTimeout has to wait for
request to time out to assert that subsequent requests does not
reuse the TCP connection.

It seems that current value of 100ms causes issues on some CI
environments and bumping the timeout seems to solve this flakiness,

We can bump the timeout value because is really low compared to real
scenarios and the bump still keeps it in the millisecond order.

Kubernetes-commit: fa68e8248594e54cda4cc06ab69030f6267ebbb7
2021-11-29 15:37:31 +01:00
Jordan Liggitt
3f1288c57f Revert sigs.k8s.io/structured-merge-diff/v4 to v4.1.2
Kubernetes-commit: d148bbcee39e3c290f9d5663e848a398d402152d
2021-11-24 10:32:24 -05:00
12 changed files with 205 additions and 30 deletions

View File

@@ -24,7 +24,7 @@ type ProbeHandlerApplyConfiguration struct {
Exec *ExecActionApplyConfiguration `json:"exec,omitempty"`
HTTPGet *HTTPGetActionApplyConfiguration `json:"httpGet,omitempty"`
TCPSocket *TCPSocketActionApplyConfiguration `json:"tcpSocket,omitempty"`
GRPC *GRPCActionApplyConfiguration `json:"gRPC,omitempty"`
GRPC *GRPCActionApplyConfiguration `json:"grpc,omitempty"`
}
// ProbeHandlerApplyConfiguration constructs an declarative configuration of the ProbeHandler type for use with

View File

@@ -5984,7 +5984,7 @@ var schemaYAML = typed.YAMLObject(`types:
- name: failureThreshold
type:
scalar: numeric
- name: gRPC
- name: grpc
type:
namedType: io.k8s.api.core.v1.GRPCAction
- name: httpGet

14
go.mod
View File

@@ -25,21 +25,21 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210825183410-e898025ed96a
golang.org/x/net v0.0.0-20211209124913-491a49abca63
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/protobuf v1.27.1
k8s.io/api v0.0.0-20211124232210-4c321cf829a0
k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a
k8s.io/api v0.23.8
k8s.io/apimachinery v0.23.8
k8s.io/klog/v2 v2.30.0
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b
sigs.k8s.io/structured-merge-diff/v4 v4.1.2
k8s.io/utils v0.0.0-20211116205334-6203023598ed
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
sigs.k8s.io/yaml v1.2.0
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20211124232210-4c321cf829a0
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a
k8s.io/api => k8s.io/api v0.23.8
k8s.io/apimachinery => k8s.io/apimachinery v0.23.8
)

20
go.sum
View File

@@ -335,8 +335,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw=
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY=
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -610,10 +610,10 @@ 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-20211124232210-4c321cf829a0 h1:hTJnV20bAHUQZIzigjK3CvWqQuzeQP/C7AP72fzzEIo=
k8s.io/api v0.0.0-20211124232210-4c321cf829a0/go.mod h1:Iod80qmyxDiUr9X93OyKup/yGuYZGx8VK8nLuWpK9Yc=
k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a h1:IggksFfccO+DgJNByne5JOJ+jfqpcMZRsYkwYGZ6qkA=
k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a/go.mod h1:fFCTTBKvKcwTPFzjlcxp91uPFZr+JA0FubU4fLzzFYc=
k8s.io/api v0.23.8 h1:tBMQ7z7s1NUUii649OaGe962xPacUzHwnGEj6Ahneu0=
k8s.io/api v0.23.8/go.mod h1:26VNldp5fRyiZ/tEO/3V8RJW+In1Aay3YkxsDzkvuWU=
k8s.io/apimachinery v0.23.8 h1:6Z+0LLvvPnAF6GXbUcBmzB1+b/AnDZpVd2N0MxUJcl0=
k8s.io/apimachinery v0.23.8/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM=
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
@@ -622,15 +622,15 @@ k8s.io/klog/v2 v2.30.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 h1:E3J9oCLlaobFUqsjG9DfKbP2BmgwBL2p7pn0A3dG9W4=
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk=
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZxKn3tKo5k/eYcs=
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20211116205334-6203023598ed h1:ck1fRPWPJWsMd8ZRFsWc6mh/zHp5fZ/shhbrgPUxDAE=
k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s=
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs=
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno=
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=

View File

@@ -413,6 +413,10 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.UserAgent == "" {
configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
}
// share the transport between all clients
httpClient, err := rest.HTTPClientFor(&configShallowCopy)
if err != nil {

View File

@@ -0,0 +1,88 @@
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kubernetes_test
import (
"context"
"net/http"
"net/http/httptest"
"testing"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
)
func TestClientUserAgent(t *testing.T) {
tests := []struct {
name string
userAgent string
expect string
}{
{
name: "empty",
expect: rest.DefaultKubernetesUserAgent(),
},
{
name: "custom",
userAgent: "test-agent",
expect: "test-agent",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
userAgent := r.Header.Get("User-Agent")
if userAgent != tc.expect {
t.Errorf("User Agent expected: %s got: %s", tc.expect, userAgent)
http.Error(w, "Unexpected user agent", http.StatusBadRequest)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write([]byte("{}"))
}))
ts.Start()
defer ts.Close()
gv := v1.SchemeGroupVersion
config := &rest.Config{
Host: ts.URL,
}
config.GroupVersion = &gv
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
config.UserAgent = tc.userAgent
config.ContentType = "application/json"
client, err := kubernetes.NewForConfig(config)
if err != nil {
t.Fatalf("failed to create REST client: %v", err)
}
_, err = client.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Error(err)
}
_, err = client.CoreV1().Secrets("").List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Error(err)
}
})
}
}

View File

@@ -1 +0,0 @@
base.go export-subst

View File

@@ -2995,7 +2995,7 @@ func TestHTTP1DoNotReuseRequestAfterTimeout(t *testing.T) {
config := &Config{
Host: ts.URL,
Transport: utilnet.SetTransportDefaults(transport),
Timeout: 100 * time.Millisecond,
Timeout: 1 * time.Second,
// These fields are required to create a REST client.
ContentConfig: ContentConfig{
GroupVersion: &schema.GroupVersion{},

View File

@@ -284,18 +284,15 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
c.indices[name] = index
}
if len(indexValues) == 1 && len(oldIndexValues) == 1 && indexValues[0] == oldIndexValues[0] {
// We optimize for the most common case where indexFunc returns a single value which has not been changed
continue
}
for _, value := range oldIndexValues {
// We optimize for the most common case where index returns a single value.
if len(indexValues) == 1 && value == indexValues[0] {
continue
}
c.deleteKeyFromIndex(key, value, index)
}
for _, value := range indexValues {
// We optimize for the most common case where index returns a single value.
if len(oldIndexValues) == 1 && value == oldIndexValues[0] {
continue
}
c.addKeyToIndex(key, value, index)
}
}

View File

@@ -18,7 +18,11 @@ package cache
import (
"fmt"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
)
func TestThreadSafeStoreDeleteRemovesEmptySetsFromIndex(t *testing.T) {
@@ -92,6 +96,75 @@ func TestThreadSafeStoreAddKeepsNonEmptySetPostDeleteFromIndex(t *testing.T) {
}
}
func TestThreadSafeStoreIndexingFunctionsWithMultipleValues(t *testing.T) {
testIndexer := "testIndexer"
indexers := Indexers{
testIndexer: func(obj interface{}) ([]string, error) {
return strings.Split(obj.(string), ","), nil
},
}
indices := Indices{}
store := NewThreadSafeStore(indexers, indices).(*threadSafeMap)
store.Add("key1", "foo")
store.Add("key2", "bar")
assert := assert.New(t)
compare := func(key string, expected []string) error {
values := store.indices[testIndexer][key].List()
if cmp.Equal(values, expected) {
return nil
}
return fmt.Errorf("unexpected index for key %s, diff=%s", key, cmp.Diff(values, expected))
}
assert.NoError(compare("foo", []string{"key1"}))
assert.NoError(compare("bar", []string{"key2"}))
store.Update("key2", "foo,bar")
assert.NoError(compare("foo", []string{"key1", "key2"}))
assert.NoError(compare("bar", []string{"key2"}))
store.Update("key1", "foo,bar")
assert.NoError(compare("foo", []string{"key1", "key2"}))
assert.NoError(compare("bar", []string{"key1", "key2"}))
store.Add("key3", "foo,bar,baz")
assert.NoError(compare("foo", []string{"key1", "key2", "key3"}))
assert.NoError(compare("bar", []string{"key1", "key2", "key3"}))
assert.NoError(compare("baz", []string{"key3"}))
store.Update("key1", "foo")
assert.NoError(compare("foo", []string{"key1", "key2", "key3"}))
assert.NoError(compare("bar", []string{"key2", "key3"}))
assert.NoError(compare("baz", []string{"key3"}))
store.Update("key2", "bar")
assert.NoError(compare("foo", []string{"key1", "key3"}))
assert.NoError(compare("bar", []string{"key2", "key3"}))
assert.NoError(compare("baz", []string{"key3"}))
store.Delete("key1")
assert.NoError(compare("foo", []string{"key3"}))
assert.NoError(compare("bar", []string{"key2", "key3"}))
assert.NoError(compare("baz", []string{"key3"}))
store.Delete("key3")
assert.NoError(compare("foo", []string{}))
assert.NoError(compare("bar", []string{"key2"}))
assert.NoError(compare("baz", []string{}))
}
func BenchmarkIndexer(b *testing.B) {
testIndexer := "testIndexer"

View File

@@ -78,6 +78,7 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
options.Limit = p.PageSize
}
requestedResourceVersion := options.ResourceVersion
requestedResourceVersionMatch := options.ResourceVersionMatch
var list *metainternalversion.List
paginatedResult := false
@@ -102,6 +103,7 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
options.Limit = 0
options.Continue = ""
options.ResourceVersion = requestedResourceVersion
options.ResourceVersionMatch = requestedResourceVersionMatch
result, err := p.PageFn(ctx, options)
return result, paginatedResult, err
}
@@ -135,10 +137,11 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
// set the next loop up
options.Continue = m.GetContinue()
// Clear the ResourceVersion on the subsequent List calls to avoid the
// Clear the ResourceVersion(Match) on the subsequent List calls to avoid the
// `specifying resource version is not allowed when using continue` error.
// See https://github.com/kubernetes/kubernetes/issues/85221#issuecomment-553748143.
options.ResourceVersion = ""
options.ResourceVersionMatch = ""
// At this point, result is already paginated.
paginatedResult = true
}

View File

@@ -76,6 +76,10 @@ func (p *testPager) PagedList(ctx context.Context, options metav1.ListOptions) (
p.t.Errorf("invariant violated, specifying resource version (%s) is not allowed when using continue (%s).", options.ResourceVersion, options.Continue)
return nil, fmt.Errorf("invariant violated")
}
if options.Continue != "" && options.ResourceVersionMatch != "" {
p.t.Errorf("invariant violated, specifying resource version match type (%s) is not allowed when using continue (%s).", options.ResourceVersionMatch, options.Continue)
return nil, fmt.Errorf("invariant violated")
}
var list metainternalversion.List
total := options.Limit
if total == 0 {
@@ -201,6 +205,13 @@ func TestListPager_List(t *testing.T) {
want: list(11, "rv:20"),
wantPaged: true,
},
{
name: "two pages with resourceVersion and resourceVersionMatch",
fields: fields{PageSize: 10, PageFn: (&testPager{t: t, expectPage: 10, remaining: 11, rv: "rv:20"}).PagedList},
args: args{options: metav1.ListOptions{ResourceVersion: "rv:10", ResourceVersionMatch: metav1.ResourceVersionMatchNotOlderThan}},
want: list(11, "rv:20"),
wantPaged: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {