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
ad4bd8bd
Commit
ad4bd8bd
authored
Jan 13, 2019
by
Tara Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add exponential backoff for plugin registration
parent
3fd7187b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
csi_client.go
pkg/volume/csi/csi_client.go
+27
-6
csi_plugin.go
pkg/volume/csi/csi_plugin.go
+0
-1
No files found.
pkg/volume/csi/csi_client.go
View file @
ad4bd8bd
...
...
@@ -22,12 +22,14 @@ import (
"fmt"
"io"
"net"
"strings"
"time"
csipbv1
"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc"
api
"k8s.io/api/core/v1"
utilversion
"k8s.io/apimachinery/pkg/util/version"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/features"
...
...
@@ -99,6 +101,12 @@ type nodeV0ClientCreator func(addr csiAddr) (
err
error
,
)
const
(
initialDuration
=
1
*
time
.
Second
factor
=
2.0
steps
=
5
)
// newV1NodeClient creates a new NodeClient with the internally used gRPC
// connection set up. It also returns a closer which must to be called to close
// the gRPC connection when the NodeClient is not used anymore.
...
...
@@ -177,13 +185,26 @@ func (c *csiDriverClient) NodeGetInfo(ctx context.Context) (
accessibleTopology
map
[
string
]
string
,
err
error
)
{
klog
.
V
(
4
)
.
Info
(
log
(
"calling NodeGetInfo rpc"
))
if
c
.
nodeV1ClientCreator
!=
nil
{
return
c
.
nodeGetInfoV1
(
ctx
)
}
else
if
c
.
nodeV0ClientCreator
!=
nil
{
return
c
.
nodeGetInfoV0
(
ctx
)
}
err
=
fmt
.
Errorf
(
"failed to call NodeGetInfo. Both nodeV1ClientCreator and nodeV0ClientCreator are nil"
)
// TODO retries should happen at a lower layer (issue #73371)
backoff
:=
wait
.
Backoff
{
Duration
:
initialDuration
,
Factor
:
factor
,
Steps
:
steps
}
err
=
wait
.
ExponentialBackoff
(
backoff
,
func
()
(
bool
,
error
)
{
var
getNodeInfoError
error
if
c
.
nodeV1ClientCreator
!=
nil
{
nodeID
,
maxVolumePerNode
,
accessibleTopology
,
getNodeInfoError
=
c
.
nodeGetInfoV1
(
ctx
)
}
else
if
c
.
nodeV0ClientCreator
!=
nil
{
nodeID
,
maxVolumePerNode
,
accessibleTopology
,
getNodeInfoError
=
c
.
nodeGetInfoV0
(
ctx
)
}
if
nodeID
!=
""
{
return
true
,
nil
}
// kubelet plugin registration service not implemented is a terminal error, no need to retry
if
strings
.
Contains
(
getNodeInfoError
.
Error
(),
"no handler registered for plugin type"
)
{
return
false
,
getNodeInfoError
}
// Continue with exponential backoff
return
false
,
nil
})
return
nodeID
,
maxVolumePerNode
,
accessibleTopology
,
err
}
...
...
pkg/volume/csi/csi_plugin.go
View file @
ad4bd8bd
...
...
@@ -159,7 +159,6 @@ func (h *RegistrationHandler) RegisterPlugin(pluginName string, endpoint string,
return
err
}
// TODO (verult) retry with exponential backoff, possibly added in csi client library.
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
csiTimeout
)
defer
cancel
()
...
...
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