Skip to content

Commit

Permalink
fix(cstor-volume-mgmt): high cpu usage caused by for {} loop
Browse files Browse the repository at this point in the history
The commit bd44756 had refactored
the cstor-volume-mgmt code to start the receivers in a for {} loop.
This caused go processes to spin more cpu.

Signed-off-by: kmova <[email protected]>
  • Loading branch information
kmova committed Nov 23, 2018
1 parent 457c5bd commit b04ac86
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions cmd/cstor-volume-mgmt/controller/start-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func StartControllers(kubeconfig string) {
cStorVolumeController := volumecontroller.NewCStorVolumeController(kubeClient, openebsClient, kubeInformerFactory,
openebsInformerFactory)

go startSharedInformerFactory(kubeInformerFactory, stopCh)
go startExternalVersionsInformerFactory(openebsInformerFactory, stopCh)
go kubeInformerFactory.Start(stopCh)
go openebsInformerFactory.Start(stopCh)

// Waitgroup for starting volume controller goroutines.
var wg sync.WaitGroup
Expand All @@ -103,18 +103,6 @@ func StartControllers(kubeconfig string) {
wg.Wait()
}

func startSharedInformerFactory(factory kubeinformers.SharedInformerFactory, stopCh <-chan struct{}) {
for {
factory.Start(stopCh)
}
}

func startExternalVersionsInformerFactory(factory informers.SharedInformerFactory, stopCh <-chan struct{}) {
for {
factory.Start(stopCh)
}
}

// GetClusterConfig return the config for k8s.
func getClusterConfig(kubeconfig string) (*rest.Config, error) {
var masterURL string
Expand Down

0 comments on commit b04ac86

Please sign in to comment.