Skip to content

apiserver: fix status code of future resourceVersion api request #131179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/storage/etcd3/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 19 additions & 0 deletions test/integration/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down