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
9c847fc4
Commit
9c847fc4
authored
Jan 16, 2018
by
vikaschoudhary16
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call Dial in blocking mode
parent
ffd5fca9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
13 deletions
+9
-13
device_plugin_stub.go
pkg/kubelet/cm/deviceplugin/device_plugin_stub.go
+6
-8
endpoint.go
pkg/kubelet/cm/deviceplugin/endpoint.go
+3
-2
manager_test.go
pkg/kubelet/cm/deviceplugin/manager_test.go
+0
-3
No files found.
pkg/kubelet/cm/deviceplugin/device_plugin_stub.go
View file @
9c847fc4
...
@@ -86,14 +86,11 @@ func (m *Stub) Start() error {
...
@@ -86,14 +86,11 @@ func (m *Stub) Start() error {
pluginapi
.
RegisterDevicePluginServer
(
m
.
server
,
m
)
pluginapi
.
RegisterDevicePluginServer
(
m
.
server
,
m
)
go
m
.
server
.
Serve
(
sock
)
go
m
.
server
.
Serve
(
sock
)
// Wait till grpc server is ready.
_
,
conn
,
err
:=
dial
(
m
.
socket
)
for
i
:=
0
;
i
<
10
;
i
++
{
if
err
!=
nil
{
services
:=
m
.
server
.
GetServiceInfo
()
return
err
if
len
(
services
)
>
0
{
break
}
time
.
Sleep
(
1
*
time
.
Second
)
}
}
conn
.
Close
()
log
.
Println
(
"Starting to serve on"
,
m
.
socket
)
log
.
Println
(
"Starting to serve on"
,
m
.
socket
)
return
nil
return
nil
...
@@ -109,7 +106,8 @@ func (m *Stub) Stop() error {
...
@@ -109,7 +106,8 @@ func (m *Stub) Stop() error {
// Register registers the device plugin for the given resourceName with Kubelet.
// Register registers the device plugin for the given resourceName with Kubelet.
func
(
m
*
Stub
)
Register
(
kubeletEndpoint
,
resourceName
string
)
error
{
func
(
m
*
Stub
)
Register
(
kubeletEndpoint
,
resourceName
string
)
error
{
conn
,
err
:=
grpc
.
Dial
(
kubeletEndpoint
,
grpc
.
WithInsecure
(),
conn
,
err
:=
grpc
.
Dial
(
kubeletEndpoint
,
grpc
.
WithInsecure
(),
grpc
.
WithBlock
(),
grpc
.
WithTimeout
(
10
*
time
.
Second
),
grpc
.
WithDialer
(
func
(
addr
string
,
timeout
time
.
Duration
)
(
net
.
Conn
,
error
)
{
grpc
.
WithDialer
(
func
(
addr
string
,
timeout
time
.
Duration
)
(
net
.
Conn
,
error
)
{
return
net
.
DialTimeout
(
"unix"
,
addr
,
timeout
)
return
net
.
DialTimeout
(
"unix"
,
addr
,
timeout
)
}))
}))
...
...
pkg/kubelet/cm/deviceplugin/endpoint.go
View file @
9c847fc4
...
@@ -186,9 +186,10 @@ func (e *endpointImpl) stop() {
...
@@ -186,9 +186,10 @@ func (e *endpointImpl) stop() {
e
.
clientConn
.
Close
()
e
.
clientConn
.
Close
()
}
}
// dial establishes the gRPC communication with the registered device plugin.
// dial establishes the gRPC communication with the registered device plugin.
https://godoc.org/google.golang.org/grpc#Dial
func
dial
(
unixSocketPath
string
)
(
pluginapi
.
DevicePluginClient
,
*
grpc
.
ClientConn
,
error
)
{
func
dial
(
unixSocketPath
string
)
(
pluginapi
.
DevicePluginClient
,
*
grpc
.
ClientConn
,
error
)
{
c
,
err
:=
grpc
.
Dial
(
unixSocketPath
,
grpc
.
WithInsecure
(),
c
,
err
:=
grpc
.
Dial
(
unixSocketPath
,
grpc
.
WithInsecure
(),
grpc
.
WithBlock
(),
grpc
.
WithTimeout
(
10
*
time
.
Second
),
grpc
.
WithDialer
(
func
(
addr
string
,
timeout
time
.
Duration
)
(
net
.
Conn
,
error
)
{
grpc
.
WithDialer
(
func
(
addr
string
,
timeout
time
.
Duration
)
(
net
.
Conn
,
error
)
{
return
net
.
DialTimeout
(
"unix"
,
addr
,
timeout
)
return
net
.
DialTimeout
(
"unix"
,
addr
,
timeout
)
}),
}),
...
...
pkg/kubelet/cm/deviceplugin/manager_test.go
View file @
9c847fc4
...
@@ -497,9 +497,6 @@ type TestResource struct {
...
@@ -497,9 +497,6 @@ type TestResource struct {
func
TestPodContainerDeviceAllocation
(
t
*
testing
.
T
)
{
func
TestPodContainerDeviceAllocation
(
t
*
testing
.
T
)
{
flag
.
Set
(
"alsologtostderr"
,
fmt
.
Sprintf
(
"%t"
,
true
))
flag
.
Set
(
"alsologtostderr"
,
fmt
.
Sprintf
(
"%t"
,
true
))
var
logLevel
string
flag
.
StringVar
(
&
logLevel
,
"logLevel"
,
"4"
,
"test"
)
flag
.
Lookup
(
"v"
)
.
Value
.
Set
(
logLevel
)
res1
:=
TestResource
{
res1
:=
TestResource
{
resourceName
:
"domain1.com/resource1"
,
resourceName
:
"domain1.com/resource1"
,
resourceQuantity
:
*
resource
.
NewQuantity
(
int64
(
2
),
resource
.
DecimalSI
),
resourceQuantity
:
*
resource
.
NewQuantity
(
int64
(
2
),
resource
.
DecimalSI
),
...
...
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