Skip to content

Commit

Permalink
Set mount concurrency to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
artemvmin committed Mar 8, 2023
1 parent ab31171 commit b162acd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
23 changes: 11 additions & 12 deletions cmd/gce-pd-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ var (
waitForOpBackoffSteps = flag.Int("wait-op-backoff-steps", 100, "Steps for wait for operation backoff")
waitForOpBackoffCap = flag.Duration("wait-op-backoff-cap", 0, "Cap for wait for operation backoff")

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

version string
)
Expand Down Expand Up @@ -88,7 +90,7 @@ func main() {
func handle() {
var err error

runtime.GOMAXPROCS(*maxprocs)
runtime.GOMAXPROCS(*maxProcs)
klog.Infof("Sys info: NumCPU: %v MAXPROC: %v", runtime.NumCPU(), runtime.GOMAXPROCS(0))

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

gceDriver := driver.GetGCEDriver()

//Initialize GCE Driver
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

//Initialize identity server
// Initialize driver
gceDriver := driver.GetGCEDriver()

// Initialize identity server
identityServer := driver.NewIdentityServer(gceDriver)

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

//Initialize requirements for the node service
// Initialize requirements for the node service
var nodeServer *driver.GCENodeServer
if *runNodeService {
mounter, err := mountmanager.NewSafeMounter()
if err != nil {
klog.Fatalf("Failed to get safe mounter: %v", err.Error())
}
mounter := mountmanager.NewSafeMounter(*maxConcurrentFormat, *concurrentFormatTimeout)
deviceUtils := deviceutils.NewDeviceUtils()
statter := mountmanager.NewStatter(mounter)
meta, err := metadataservice.NewMetadataService()
Expand Down
13 changes: 5 additions & 8 deletions pkg/mount-manager/safe-mounter_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ limitations under the License.
package mountmanager

import (
"time"

"k8s.io/mount-utils"
"k8s.io/utils/exec"
)

func NewSafeMounter() (*mount.SafeFormatAndMount, error) {
realMounter := mount.New("")
realExec := exec.New()
return &mount.SafeFormatAndMount{
Interface: realMounter,
Exec: realExec,
}, nil

func NewSafeMounter(maxConcurrentFormat int, concurrentFormatTimeout time.Duration) *mount.SafeFormatAndMount {
opt := mount.WithMaxConcurrentFormat(maxConcurrentFormat, concurrentFormatTimeout)
return mount.NewSafeFormatAndMount(mount.New(""), exec.New(), opt)
}

0 comments on commit b162acd

Please sign in to comment.