Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 48ba9a4

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #55944 from edisonxiang/probeimprovecinder
Automatic merge from submit-queue (batch tested with PRs 55925, 55999, 55944, 55992, 56196). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. probeAttachedVolume improvement in Cinder What this PR does / why we need it: During OpenStack Cinder volume attachment, kubelet creates too many udev "change" events. If volume attachement takes long, then udev event queue gets full,therefore udev does not answer requests from docker, and makes Kubernetes node unhealthy. This patch will extend the udevadm trigger period, and use the udevadm settle to ensure that any device nodes have been created successfully before proceeding. Fixes #55007 Release note: ```release-note None ``` /cc @dims @kabakaev
2 parents 077cd27 + fdfb545 commit 48ba9a4

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

pkg/volume/cinder/attacher.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ var _ volume.Attacher = &cinderDiskAttacher{}
4444
var _ volume.AttachableVolumePlugin = &cinderPlugin{}
4545

4646
const (
47-
checkSleepDuration = 1 * time.Second
48-
operationFinishInitDealy = 1 * time.Second
47+
probeVolumeInitDelay = 1 * time.Second
48+
probeVolumeFactor = 2.0
49+
operationFinishInitDelay = 1 * time.Second
4950
operationFinishFactor = 1.1
5051
operationFinishSteps = 10
51-
diskAttachInitDealy = 1 * time.Second
52+
diskAttachInitDelay = 1 * time.Second
5253
diskAttachFactor = 1.2
5354
diskAttachSteps = 15
54-
diskDetachInitDealy = 1 * time.Second
55+
diskDetachInitDelay = 1 * time.Second
5556
diskDetachFactor = 1.2
5657
diskDetachSteps = 13
5758
)
@@ -74,7 +75,7 @@ func (plugin *cinderPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string
7475

7576
func (attacher *cinderDiskAttacher) waitOperationFinished(volumeID string) error {
7677
backoff := wait.Backoff{
77-
Duration: operationFinishInitDealy,
78+
Duration: operationFinishInitDelay,
7879
Factor: operationFinishFactor,
7980
Steps: operationFinishSteps,
8081
}
@@ -99,7 +100,7 @@ func (attacher *cinderDiskAttacher) waitOperationFinished(volumeID string) error
99100

100101
func (attacher *cinderDiskAttacher) waitDiskAttached(instanceID, volumeID string) error {
101102
backoff := wait.Backoff{
102-
Duration: diskAttachInitDealy,
103+
Duration: diskAttachInitDelay,
103104
Factor: diskAttachFactor,
104105
Steps: diskAttachSteps,
105106
}
@@ -234,11 +235,12 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath
234235
return "", fmt.Errorf("WaitForAttach failed for Cinder disk %q: devicePath is empty.", volumeID)
235236
}
236237

237-
ticker := time.NewTicker(checkSleepDuration)
238+
ticker := time.NewTicker(probeVolumeInitDelay)
238239
defer ticker.Stop()
239240
timer := time.NewTimer(timeout)
240241
defer timer.Stop()
241242

243+
duration := probeVolumeInitDelay
242244
for {
243245
select {
244246
case <-ticker.C:
@@ -255,6 +257,10 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath
255257
} else {
256258
// Log an error, and continue checking periodically
257259
glog.Errorf("Error: could not find attached Cinder disk %q (path: %q): %v", volumeID, devicePath, err)
260+
// Using exponential backoff instead of linear
261+
ticker.Stop()
262+
duration = time.Duration(float64(duration) * probeVolumeFactor)
263+
ticker = time.NewTicker(duration)
258264
}
259265
case <-timer.C:
260266
return "", fmt.Errorf("Could not find attached Cinder disk %q. Timeout waiting for mount paths to be created.", volumeID)
@@ -328,7 +334,7 @@ func (plugin *cinderPlugin) NewDetacher() (volume.Detacher, error) {
328334

329335
func (detacher *cinderDiskDetacher) waitOperationFinished(volumeID string) error {
330336
backoff := wait.Backoff{
331-
Duration: operationFinishInitDealy,
337+
Duration: operationFinishInitDelay,
332338
Factor: operationFinishFactor,
333339
Steps: operationFinishSteps,
334340
}
@@ -353,7 +359,7 @@ func (detacher *cinderDiskDetacher) waitOperationFinished(volumeID string) error
353359

354360
func (detacher *cinderDiskDetacher) waitDiskDetached(instanceID, volumeID string) error {
355361
backoff := wait.Backoff{
356-
Duration: diskDetachInitDealy,
362+
Duration: diskDetachInitDelay,
357363
Factor: diskDetachFactor,
358364
Steps: diskDetachSteps,
359365
}

pkg/volume/cinder/cinder_util.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ func probeAttachedVolume() error {
224224
scsiHostRescan()
225225

226226
executor := exec.New()
227+
228+
// udevadm settle waits for udevd to process the device creation
229+
// events for all hardware devices, thus ensuring that any device
230+
// nodes have been created successfully before proceeding.
231+
argsSettle := []string{"settle"}
232+
cmdSettle := executor.Command("udevadm", argsSettle...)
233+
_, errSettle := cmdSettle.CombinedOutput()
234+
if errSettle != nil {
235+
glog.Errorf("error running udevadm settle %v\n", errSettle)
236+
}
237+
227238
args := []string{"trigger"}
228239
cmd := executor.Command("udevadm", args...)
229240
_, err := cmd.CombinedOutput()

0 commit comments

Comments
 (0)