diff --git a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/errors.go b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/errors.go index 7dd91d94958ea..6e9bee815aa11 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/errors.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/errors.go @@ -70,6 +70,8 @@ func interpretListError(err error, paging bool, continueKey, keyPrefix string) e return handleCompactedErrorForPaging(continueKey, keyPrefix) } return errors.NewResourceExpired(expired) + case goerrors.Is(err, etcdrpc.ErrFutureRev): + return errors.NewTimeoutError(etcdrpc.ErrFutureRev.Error(), 0) } return err } diff --git a/test/integration/apiserver/apiserver_test.go b/test/integration/apiserver/apiserver_test.go index b8d7e66607830..1a95ebfad7e15 100644 --- a/test/integration/apiserver/apiserver_test.go +++ b/test/integration/apiserver/apiserver_test.go @@ -234,6 +234,25 @@ func Test4xxStatusCodeInvalidPatch(t *testing.T) { } } +func TestResourceVersionFutureRev(t *testing.T) { + ctx, client, _, tearDownFn := setup(t) + defer tearDownFn() + + var statusCode int + + result := client.AppsV1().RESTClient(). + Get(). + Resource("deployments"). + Param("resourceVersion", "2147483647"). + Param("limit", "1"). + Do(ctx) + result.StatusCode(&statusCode) + + if statusCode != http.StatusGatewayTimeout { + t.Fatalf("Expected status code to be 504, got %v (%#v)", statusCode, result) + } +} + func TestCacheControl(t *testing.T) { server := kubeapiservertesting.StartTestServerOrDie(t, nil, framework.DefaultTestServerFlags(), framework.SharedEtcd()) defer server.TearDownFn()