Skip to content

Commit

Permalink
NEX-23686 Increase timeout for iSCSI device scan (#38)
Browse files Browse the repository at this point in the history
* NEX-23686 Increase timeout for iSCSI device scan
  • Loading branch information
Qeas authored Oct 13, 2023
1 parent 27fd612 commit c977881
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ifeq (${VERSION}, master)
--k8sDeploymentFile="/tmp/nexentastor-csi-driver-block-local.yaml" \
--k8sSecretFile="./_configs/driver-config-single-default.yaml"
else
sed -e "s/image: nexenta\/nexentastor-csi-driver-block:master/image: ${REGISTRY_LOCAL}\/nexentastor-csi-driver-block:v${VERSION}/g" \
sed -E "s/image: nexenta\/nexentastor-csi-driver-block:v.+/image: ${REGISTRY_LOCAL}\/nexentastor-csi-driver-block:v${VERSION}/g" \
./deploy/kubernetes/nexentastor-csi-driver-block.yaml > /tmp/nexentastor-csi-driver-block-local.yaml
go test -timeout 20m tests/e2e/driver_test.go -v -count 1 \
--k8sConnectionString="root@${TEST_K8S_IP}" \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Releases can be found here - https://github.com/Nexenta/nexentastor-csi-driver-b
| `debug` | print more logs (default: false) | no | `true` |
| `zone` | Zone to match topology.kubernetes.io/zone. | no | `us-west` |
|`insecureSkipVerify`| TLS certificates check will be skipped when `true` (default: 'true')| no | `false` |
|`iSCSITimeout`| Maximum time for iSCSI device discovery (default: '300')| no | `200` |

**Note**: if parameter `defaultVolumeGroup`/`defaultDataIp` is not specified in driver configuration,
then parameter `volumeGroup`/`dataIp` must be specified in _StorageClass_ configuration.
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type NsData struct {
DefaultISCSIPort string `yaml:"defaultiSCSIPort,omitempty"`
DefaultDataIP string `yaml:"defaultDataIp,omitempty"`
ISCSITargetPrefix string `yaml:"iSCSITargetPrefix,omitempty"`
ISCSITimeout string `yaml:"iSCSITimeout,omitempty"`
DynamicTargetLunAllocation *bool `yaml:"dynamicTargetLunAllocation"`
NumOfLunsPerTarget string `yaml:"numOfLunsPerTarget"`
UseChapAuth string `yaml:"useChapAuth"`
Expand Down
32 changes: 26 additions & 6 deletions pkg/driver/nodeServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ISCSIVolumeContext struct {
ChapSecret string
NumOfLunsPerTarget int
UseChapAuth bool
ISCSITimeout int
}

const (
Expand All @@ -63,6 +64,7 @@ const (
DefaultUseChapAuth = false
DefaultMountPointPermissions = 0750
DefaultFindMntTimeout = 90
DefaultISCSITimeout = 300
)


Expand Down Expand Up @@ -384,6 +386,14 @@ func (s *NodeServer) ParseVolumeContext(
) {
l := s.log.WithField("func", "ParseVolumeContext()")
cfg := s.config.NsMap[configName]
parsedContext.ISCSITimeout = DefaultISCSITimeout
if cfg.ISCSITimeout != "" {
parsedContext.ISCSITimeout, err = strconv.Atoi(cfg.ISCSITimeout)
if err != nil {
l.Infof("Could not parse ISCSITimeout, setting default: %+v", DefaultISCSITimeout)
parsedContext.ISCSITimeout = DefaultISCSITimeout
}
}
parsedContext.TargetGroup = volumeContext["TargetGroup"]
parsedContext.ISCSITarget = volumeContext["Target"]
parsedContext.ISCSITargetPrefix = cfg.ISCSITargetPrefix
Expand Down Expand Up @@ -620,14 +630,20 @@ func (s *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolu

devByPath := s.ConstructDevByPath(portal, iSCSITarget, lunNumber)
found := false
sleepTime := 500 * time.Millisecond
timeout := 60 * time.Second
sleepTime := 1 * time.Second
timeout := parsedContext.ISCSITimeout

for !found {
if sleepTime > timeout {
return nil, status.Error(codes.DeadlineExceeded, "Mount is nil in volume capability")
if sleepTime > time.Duration(timeout) * time.Second {
return nil, status.Errorf(
codes.DeadlineExceeded, "Could not find iSCSI device in %v seconds", timeout)
}
err = s.ISCSILogInRescan(iSCSITarget, portal)
if err != nil {
return nil, err
}
if _, err := os.Stat(filepath.Join("/host", devByPath)); os.IsNotExist(err) {
l.Infof("Device %s not found, sleep %s", devByPath, sleepTime)
l.Infof("Device %s not found, sleep %v", devByPath, sleepTime)
time.Sleep(sleepTime)
sleepTime *= 2
} else {
Expand Down Expand Up @@ -1114,7 +1130,11 @@ func (s *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCa
*csi.NodeGetCapabilitiesResponse,
error,
) {
s.log.WithField("func", "NodeGetCapabilities()").Infof("request: '%+v'", req)
if len(req.String()) != 0 {
s.log.WithField("func", "NodeGetCapabilities()").Infof("request: '%+v'", req)
} else {
s.log.WithField("func", "NodeGetCapabilities()").Debugf("request: '%+v'", req)
}

return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{
Expand Down

0 comments on commit c977881

Please sign in to comment.