Skip to content

Commit

Permalink
add --timeout for gRPC calls
Browse files Browse the repository at this point in the history
The one second timeout is based on the assumption that once the
connection is established, all further communication is going to be
fast.

That assumption doesn't hold in some special circumstances:
- interactively debugging the sidecar
- proxying the driver operation to some remote implementation

While this is a bit obscure, the flag is essential for these
cases. Adding the flag also makes the node-driver-registrar consistent
with other sidecars.
  • Loading branch information
pohly committed Dec 10, 2020
1 parent ba2b6cc commit 5093e97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ There are two UNIX domain sockets used by the node-driver-registrar:
node-driver-registrar, which checks if the registration socket exists. A value <= 0 disables
the server. Server is disabled by default.

* `--timeout <duration>`: Timeout of all calls to CSI driver. It should be set to a value that accommodates the `GetDriverName` calls. 1 second is used by default.

### Required permissions

The node-driver-registrar does not interact with the Kubernetes API, so no RBAC
Expand Down
6 changes: 2 additions & 4 deletions cmd/csi-node-driver-registrar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ const (
// names
annotationKey = "csi.volume.kubernetes.io/nodeid"

// Default timeout of short CSI calls like GetPluginInfo
csiTimeout = time.Second

// Verify (and update, if needed) the node ID at this frequency.
sleepDuration = 2 * time.Minute
)

// Command line flags
var (
connectionTimeout = flag.Duration("connection-timeout", 0, "The --connection-timeout flag is deprecated")
operationTimeout = flag.Duration("timeout", time.Second, "Timeout for waiting for communication with driver")
csiAddress = flag.String("csi-address", "/run/csi/socket", "Path of the CSI driver socket that the node-driver-registrar will connect to.")
pluginRegistrationPath = flag.String("plugin-registration-path", "/registration", "Path to Kubernetes plugin registration directory.")
kubeletRegistrationPath = flag.String("kubelet-registration-path", "", "Path of the CSI driver socket on the Kubernetes host machine.")
Expand Down Expand Up @@ -144,7 +142,7 @@ func main() {
}

klog.V(1).Infof("Calling CSI driver to discover driver name")
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
ctx, cancel := context.WithTimeout(context.Background(), *operationTimeout)
defer cancel()

csiDriverName, err := csirpc.GetDriverName(ctx, csiConn)
Expand Down

0 comments on commit 5093e97

Please sign in to comment.