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
b48e7b22
Commit
b48e7b22
authored
Mar 26, 2018
by
hangaoshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use status.Errorf instead of Deprecated func grpc.Errorf
parent
3a2fe7b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
BUILD
pkg/kubelet/server/streaming/BUILD
+1
-0
errors.go
pkg/kubelet/server/streaming/errors.go
+3
-2
server.go
pkg/kubelet/server/streaming/server.go
+8
-8
No files found.
pkg/kubelet/server/streaming/BUILD
View file @
b48e7b22
...
...
@@ -21,6 +21,7 @@ go_library(
"//vendor/github.com/emicklei/go-restful:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
"//vendor/google.golang.org/grpc/codes:go_default_library",
"//vendor/google.golang.org/grpc/status:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/remotecommand:go_default_library",
...
...
pkg/kubelet/server/streaming/errors.go
View file @
b48e7b22
...
...
@@ -23,15 +23,16 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func
ErrorStreamingDisabled
(
method
string
)
error
{
return
grpc
.
Errorf
(
codes
.
NotFound
,
fmt
.
Sprintf
(
"streaming method %s disabled"
,
method
))
return
status
.
Errorf
(
codes
.
NotFound
,
fmt
.
Sprintf
(
"streaming method %s disabled"
,
method
))
}
// The error returned when the maximum number of in-flight requests is exceeded.
func
ErrorTooManyInFlight
()
error
{
return
grpc
.
Errorf
(
codes
.
ResourceExhausted
,
"maximum number of in-flight requests exceeded"
)
return
status
.
Errorf
(
codes
.
ResourceExhausted
,
"maximum number of in-flight requests exceeded"
)
}
// Translates a CRI streaming error into an appropriate HTTP response.
...
...
pkg/kubelet/server/streaming/server.go
View file @
b48e7b22
...
...
@@ -25,8 +25,8 @@ import (
"path"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
restful
"github.com/emicklei/go-restful"
...
...
@@ -160,15 +160,15 @@ type server struct {
func
validateExecRequest
(
req
*
runtimeapi
.
ExecRequest
)
error
{
if
req
.
ContainerId
==
""
{
return
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"missing required container_id"
)
return
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing required container_id"
)
}
if
req
.
Tty
&&
req
.
Stderr
{
// If TTY is set, stderr cannot be true because multiplexing is not
// supported.
return
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"tty and stderr cannot both be true"
)
return
status
.
Errorf
(
codes
.
InvalidArgument
,
"tty and stderr cannot both be true"
)
}
if
!
req
.
Stdin
&&
!
req
.
Stdout
&&
!
req
.
Stderr
{
return
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"one of stdin, stdout, or stderr must be set"
)
return
status
.
Errorf
(
codes
.
InvalidArgument
,
"one of stdin, stdout, or stderr must be set"
)
}
return
nil
}
...
...
@@ -188,15 +188,15 @@ func (s *server) GetExec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse,
func
validateAttachRequest
(
req
*
runtimeapi
.
AttachRequest
)
error
{
if
req
.
ContainerId
==
""
{
return
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"missing required container_id"
)
return
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing required container_id"
)
}
if
req
.
Tty
&&
req
.
Stderr
{
// If TTY is set, stderr cannot be true because multiplexing is not
// supported.
return
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"tty and stderr cannot both be true"
)
return
status
.
Errorf
(
codes
.
InvalidArgument
,
"tty and stderr cannot both be true"
)
}
if
!
req
.
Stdin
&&
!
req
.
Stdout
&&
!
req
.
Stderr
{
return
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"one of stdin, stdout, and stderr must be set"
)
return
status
.
Errorf
(
codes
.
InvalidArgument
,
"one of stdin, stdout, and stderr must be set"
)
}
return
nil
}
...
...
@@ -216,7 +216,7 @@ func (s *server) GetAttach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachRes
func
(
s
*
server
)
GetPortForward
(
req
*
runtimeapi
.
PortForwardRequest
)
(
*
runtimeapi
.
PortForwardResponse
,
error
)
{
if
req
.
PodSandboxId
==
""
{
return
nil
,
grpc
.
Errorf
(
codes
.
InvalidArgument
,
"missing required pod_sandbox_id"
)
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing required pod_sandbox_id"
)
}
token
,
err
:=
s
.
cache
.
Insert
(
req
)
if
err
!=
nil
{
...
...
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