Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
60d83657
Unverified
Commit
60d83657
authored
Feb 27, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Server timeout returns an incorrect error
Not a valid Status object in JSON
parent
70797f51
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
timeout.go
staging/src/k8s.io/apiserver/pkg/server/filters/timeout.go
+1
-1
timeout_test.go
...g/src/k8s.io/apiserver/pkg/server/filters/timeout_test.go
+12
-5
BUILD
vendor/BUILD
+2
-0
No files found.
staging/src/k8s.io/apiserver/pkg/server/filters/timeout.go
View file @
60d83657
...
...
@@ -197,7 +197,7 @@ func (tw *baseTimeoutWriter) timeout(err *apierrors.StatusError) {
if
!
tw
.
wroteHeader
&&
!
tw
.
hijacked
{
tw
.
w
.
WriteHeader
(
http
.
StatusGatewayTimeout
)
enc
:=
json
.
NewEncoder
(
tw
.
w
)
enc
.
Encode
(
err
)
enc
.
Encode
(
&
err
.
ErrStatus
)
}
else
{
// The timeout writer has been used by the inner handler. There is
// no way to timeout the HTTP request at the point. We have to shutdown
...
...
staging/src/k8s.io/apiserver/pkg/server/filters/timeout_test.go
View file @
60d83657
...
...
@@ -17,15 +17,18 @@ limitations under the License.
package
filters
import
(
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"time"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"
strings
"
"
k8s.io/apimachinery/pkg/util/diff
"
)
func
TestTimeout
(
t
*
testing
.
T
)
{
...
...
@@ -50,7 +53,7 @@ func TestTimeout(t *testing.T) {
sendResponse
<-
struct
{}{}
res
,
err
:=
http
.
Get
(
ts
.
URL
)
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
if
res
.
StatusCode
!=
http
.
StatusOK
{
t
.
Errorf
(
"got res.StatusCode %d; expected %d"
,
res
.
StatusCode
,
http
.
StatusOK
)
...
...
@@ -67,14 +70,18 @@ func TestTimeout(t *testing.T) {
timeout
<-
time
.
Time
{}
res
,
err
=
http
.
Get
(
ts
.
URL
)
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
if
res
.
StatusCode
!=
http
.
StatusGatewayTimeout
{
t
.
Errorf
(
"got res.StatusCode %d; expected %d"
,
res
.
StatusCode
,
http
.
StatusServiceUnavailable
)
}
body
,
_
=
ioutil
.
ReadAll
(
res
.
Body
)
if
!
strings
.
Contains
(
string
(
body
),
timeoutErr
.
Error
())
{
t
.
Errorf
(
"got body %q; expected it to contain %q"
,
string
(
body
),
timeoutErr
.
Error
())
status
:=
&
metav1
.
Status
{}
if
err
:=
json
.
Unmarshal
(
body
,
status
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
reflect
.
DeepEqual
(
status
,
&
timeoutErr
.
ErrStatus
)
{
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectReflectDiff
(
&
timeoutErr
.
ErrStatus
,
status
))
}
// Now try to send a response
...
...
vendor/BUILD
View file @
60d83657
...
...
@@ -10399,7 +10399,9 @@ go_test(
tags = ["automanaged"],
deps = [
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/util/diff",
"//vendor:k8s.io/apimachinery/pkg/util/sets",
"//vendor:k8s.io/apiserver/pkg/endpoints/filters",
"//vendor:k8s.io/apiserver/pkg/endpoints/request",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment