Skip to content

Commit 7fa4acd

Browse files
committed
Set mkfs concurrency limit to 1
1 parent 232bd0a commit 7fa4acd

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

cmd/gce-pd-csi-driver/main.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ var (
5959
waitForOpBackoffSteps = flag.Int("wait-op-backoff-steps", 100, "Steps for wait for operation backoff")
6060
waitForOpBackoffCap = flag.Duration("wait-op-backoff-cap", 0, "Cap for wait for operation backoff")
6161

62-
maxprocs = flag.Int("maxprocs", 1, "GOMAXPROCS override")
62+
maxProcs = flag.Int("maxprocs", 1, "GOMAXPROCS override")
63+
maxConcurrentFormat = flag.Int("max-concurrent-format", 1, "The maximum number of concurrent format exec calls")
64+
concurrentFormatTimeout = flag.Duration("concurrent-format-timeout", 1*time.Minute, "The maximum duration of a format operation before its concurrency token is released")
6365

6466
version string
6567
)
@@ -88,7 +90,7 @@ func main() {
8890
func handle() {
8991
var err error
9092

91-
runtime.GOMAXPROCS(*maxprocs)
93+
runtime.GOMAXPROCS(*maxProcs)
9294
klog.Infof("Sys info: NumCPU: %v MAXPROC: %v", runtime.NumCPU(), runtime.GOMAXPROCS(0))
9395

9496
if version == "" {
@@ -110,16 +112,16 @@ func handle() {
110112
klog.Fatalf("Bad extra volume labels: %v", err.Error())
111113
}
112114

113-
gceDriver := driver.GetGCEDriver()
114-
115-
//Initialize GCE Driver
116115
ctx, cancel := context.WithCancel(context.Background())
117116
defer cancel()
118117

119-
//Initialize identity server
118+
// Initialize driver
119+
gceDriver := driver.GetGCEDriver()
120+
121+
// Initialize identity server
120122
identityServer := driver.NewIdentityServer(gceDriver)
121123

122-
//Initialize requirements for the controller service
124+
// Initialize requirements for the controller service
123125
var controllerServer *driver.GCEControllerServer
124126
if *runControllerService {
125127
cloudProvider, err := gce.CreateCloudProvider(ctx, version, *cloudConfigFilePath, *computeEndpoint)
@@ -133,13 +135,10 @@ func handle() {
133135
klog.Warningf("controller service is disabled but cloud config given - it has no effect")
134136
}
135137

136-
//Initialize requirements for the node service
138+
// Initialize requirements for the node service
137139
var nodeServer *driver.GCENodeServer
138140
if *runNodeService {
139-
mounter, err := mountmanager.NewSafeMounter()
140-
if err != nil {
141-
klog.Fatalf("Failed to get safe mounter: %v", err.Error())
142-
}
141+
mounter := mountmanager.NewSafeMounter(*maxConcurrentFormat, *concurrentFormatTimeout)
143142
deviceUtils := deviceutils.NewDeviceUtils()
144143
statter := mountmanager.NewStatter(mounter)
145144
meta, err := metadataservice.NewMetadataService()

pkg/mount-manager/safe-mounter_linux.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ limitations under the License.
1717
package mountmanager
1818

1919
import (
20+
"time"
21+
2022
"k8s.io/mount-utils"
2123
"k8s.io/utils/exec"
2224
)
2325

24-
func NewSafeMounter() (*mount.SafeFormatAndMount, error) {
25-
realMounter := mount.New("")
26-
realExec := exec.New()
27-
return &mount.SafeFormatAndMount{
28-
Interface: realMounter,
29-
Exec: realExec,
30-
}, nil
31-
26+
func NewSafeMounter(maxConcurrentFormat int, concurrentFormatTimeout time.Duration) *mount.SafeFormatAndMount {
27+
opt := mount.WithMaxConcurrentFormat(maxConcurrentFormat, concurrentFormatTimeout)
28+
return mount.NewSafeFormatAndMount(mount.New(""), exec.New(), opt)
3229
}

0 commit comments

Comments
 (0)