Skip to content

Commit 5aa6a71

Browse files
authored
Merge pull request #2439 from shuheiktgw/fail_cache_continue
⚠️ Return an error if the continue list option is set for the cache reader
2 parents 5bf44d2 + 674087d commit 5aa6a71

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/cache/cache_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,14 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
688688
Expect(informerCache.List(context.Background(), listObj, labelOpt, limitOpt)).To(Succeed())
689689
Expect(listObj.Items).Should(HaveLen(1))
690690
})
691+
692+
It("should return an error if the continue list options is set", func() {
693+
listObj := &corev1.PodList{}
694+
continueOpt := client.Continue("token")
695+
By("verifying that an error is returned")
696+
err := informerCache.List(context.Background(), listObj, continueOpt)
697+
Expect(err).To(HaveOccurred())
698+
})
691699
})
692700

693701
Context("with unstructured objects", func() {
@@ -1002,6 +1010,13 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
10021010
Expect(nodeList.Items).NotTo(BeEmpty())
10031011
Expect(len(nodeList.Items)).To(BeEquivalentTo(1))
10041012
})
1013+
It("should return an error if the continue list options is set", func() {
1014+
podList := &unstructured.Unstructured{}
1015+
continueOpt := client.Continue("token")
1016+
By("verifying that an error is returned")
1017+
err := informerCache.List(context.Background(), podList, continueOpt)
1018+
Expect(err).To(HaveOccurred())
1019+
})
10051020
})
10061021
Context("with metadata-only objects", func() {
10071022
It("should be able to list objects that haven't been watched previously", func() {

pkg/cache/internal/cache_reader.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ func (c *CacheReader) List(_ context.Context, out client.ObjectList, opts ...cli
111111
listOpts := client.ListOptions{}
112112
listOpts.ApplyOptions(opts)
113113

114+
if listOpts.Continue != "" {
115+
return fmt.Errorf("continue list option is not supported by the cache")
116+
}
117+
114118
switch {
115119
case listOpts.FieldSelector != nil:
116120
// TODO(directxman12): support more complicated field selectors by

0 commit comments

Comments
 (0)