mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-21 17:15:35 +00:00
fixing large resourceversion and limit for storages
This commit is contained in:
@@ -19,6 +19,7 @@ package etcd3
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"reflect"
|
||||
@@ -31,6 +32,7 @@ import (
|
||||
"go.etcd.io/etcd/client/v3/kubernetes"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
|
||||
etcdrpc "go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
@@ -744,6 +746,14 @@ func (s *store) GetList(ctx context.Context, key string, opts storage.ListOption
|
||||
})
|
||||
metrics.RecordEtcdRequest(metricsOp, s.groupResource, err, startTime)
|
||||
if err != nil {
|
||||
if errors.Is(err, etcdrpc.ErrFutureRev) {
|
||||
currentRV, getRVErr := s.GetCurrentResourceVersion(ctx)
|
||||
if getRVErr != nil {
|
||||
// If we can't get the current RV, use 0 as a fallback.
|
||||
currentRV = 0
|
||||
}
|
||||
return storage.NewTooLargeResourceVersionError(uint64(withRev), currentRV, 0)
|
||||
}
|
||||
return interpretListError(err, len(opts.Predicate.Continue) > 0, continueKey, keyPrefix)
|
||||
}
|
||||
numFetched += len(getResp.Kvs)
|
||||
|
||||
@@ -1608,9 +1608,8 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface, inc
|
||||
listCtx := context.WithValue(ctx, recorderContextKey, recorderKey)
|
||||
err := store.GetList(listCtx, tt.prefix, storageOpts, out)
|
||||
if tt.expectRVTooLarge {
|
||||
// TODO: Clasify etcd future revision error as TooLargeResourceVersion
|
||||
if err == nil || !(storage.IsTooLargeResourceVersion(err) || strings.Contains(err.Error(), "etcdserver: mvcc: required revision is a future revision")) {
|
||||
t.Fatalf("expecting resource version too high error, but get: %q", err)
|
||||
if !storage.IsTooLargeResourceVersion(err) {
|
||||
t.Fatalf("expecting resource version too high error, but get: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user