@@ -627,17 +627,13 @@ func (s *store) GetList(ctx context.Context, key string, opts storage.ListOption
627
627
limitOption = & options [len (options )- 1 ]
628
628
}
629
629
630
- newItemFunc := getNewItemFunc (listObj , v )
631
-
632
- var fromRV * uint64
633
- if len (opts .ResourceVersion ) > 0 {
634
- parsedRV , err := s .versioner .ParseResourceVersion (opts .ResourceVersion )
635
- if err != nil {
636
- return apierrors .NewBadRequest (fmt .Sprintf ("invalid resource version: %v" , err ))
637
- }
638
- fromRV = & parsedRV
630
+ if opts .Recursive {
631
+ rangeEnd := clientv3 .GetPrefixRangeEnd (keyPrefix )
632
+ options = append (options , clientv3 .WithRange (rangeEnd ))
639
633
}
640
634
635
+ newItemFunc := getNewItemFunc (listObj , v )
636
+
641
637
var continueRV , withRev int64
642
638
var continueKey string
643
639
switch {
@@ -657,28 +653,26 @@ func (s *store) GetList(ctx context.Context, key string, opts storage.ListOption
657
653
if continueRV > 0 {
658
654
withRev = continueRV
659
655
}
660
- default :
661
- if fromRV != nil {
662
- switch opts . ResourceVersionMatch {
663
- case metav1 . ResourceVersionMatchNotOlderThan :
664
- // The not older than constraint is checked after we get a response from etcd,
665
- // and returnedRV is then set to the revision we get from the etcd response.
666
- case metav1 .ResourceVersionMatchExact :
667
- withRev = int64 ( * fromRV )
668
- case "" : // legacy case
669
- if opts . Recursive && opts . Predicate . Limit > 0 && * fromRV > 0 {
670
- withRev = int64 (* fromRV )
671
- }
672
- default :
673
- return fmt . Errorf ( "unknown ResourceVersionMatch value: %v" , opts . ResourceVersionMatch )
656
+ case len ( opts . ResourceVersion ) > 0 :
657
+ parsedRV , err := s . versioner . ParseResourceVersion ( opts . ResourceVersion )
658
+ if err != nil {
659
+ return apierrors . NewBadRequest ( fmt . Sprintf ( "invalid resource version: %v" , err ))
660
+ }
661
+ switch opts . ResourceVersionMatch {
662
+ case metav1 .ResourceVersionMatchNotOlderThan :
663
+ // The not older than constraint is checked after we get a response from etcd,
664
+ // and returnedRV is then set to the revision we get from the etcd response.
665
+ case metav1 . ResourceVersionMatchExact :
666
+ withRev = int64 (parsedRV )
667
+ case "" : // legacy case
668
+ if opts . Recursive && opts . Predicate . Limit > 0 && parsedRV > 0 {
669
+ withRev = int64 ( parsedRV )
674
670
}
671
+ default :
672
+ return fmt .Errorf ("unknown ResourceVersionMatch value: %v" , opts .ResourceVersionMatch )
675
673
}
676
674
}
677
675
678
- if opts .Recursive {
679
- rangeEnd := clientv3 .GetPrefixRangeEnd (keyPrefix )
680
- options = append (options , clientv3 .WithRange (rangeEnd ))
681
- }
682
676
if withRev != 0 {
683
677
options = append (options , clientv3 .WithRev (withRev ))
684
678
}
@@ -717,6 +711,11 @@ func (s *store) GetList(ctx context.Context, key string, opts storage.ListOption
717
711
if len (getResp .Kvs ) == 0 && getResp .More {
718
712
return fmt .Errorf ("no results were found, but etcd indicated there were more values remaining" )
719
713
}
714
+ // indicate to the client which resource version was returned, and use the same resource version for subsequent requests.
715
+ if withRev == 0 {
716
+ withRev = getResp .Header .Revision
717
+ options = append (options , clientv3 .WithRev (withRev ))
718
+ }
720
719
721
720
// avoid small allocations for the result slice, since this can be called in many
722
721
// different contexts and we don't know how significantly the result will be filtered
@@ -776,14 +775,6 @@ func (s *store) GetList(ctx context.Context, key string, opts storage.ListOption
776
775
* limitOption = clientv3 .WithLimit (limit )
777
776
}
778
777
preparedKey = string (lastKey ) + "\x00 "
779
- if withRev == 0 {
780
- withRev = getResp .Header .Revision
781
- options = append (options , clientv3 .WithRev (withRev ))
782
- }
783
- }
784
- // indicate to the client which resource version was returned
785
- if withRev == 0 {
786
- withRev = getResp .Header .Revision
787
778
}
788
779
789
780
if v .IsNil () {
0 commit comments