File tree Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
2323 "fmt"
2424 _ "net/http/pprof"
2525 "os"
26+ goruntime "runtime"
2627 "time"
2728
2829 // +kubebuilder:scaffold:imports
8182 watchFilterValue string
8283 watchNamespace string
8384 profilerAddress string
85+ enableContentionProfiling bool
8486 clusterConcurrency int
8587 kubeadmConfigConcurrency int
8688 syncPeriod time.Duration
@@ -119,6 +121,9 @@ func InitFlags(fs *pflag.FlagSet) {
119121 fs .StringVar (& profilerAddress , "profiler-address" , "" ,
120122 "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
121123
124+ fs .BoolVar (& enableContentionProfiling , "contention-profiling" , false ,
125+ "Enable block profiling, if profiler-address is set." )
126+
122127 fs .IntVar (& clusterConcurrency , "cluster-concurrency" , 10 ,
123128 "Number of clusters to process simultaneously" )
124129
@@ -184,6 +189,10 @@ func main() {
184189 watchNamespaces = []string {watchNamespace }
185190 }
186191
192+ if profilerAddress != "" && enableContentionProfiling {
193+ goruntime .SetBlockProfileRate (1 )
194+ }
195+
187196 ctrlOptions := ctrl.Options {
188197 Scheme : scheme ,
189198 MetricsBindAddress : metricsBindAddr ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
2323 "fmt"
2424 _ "net/http/pprof"
2525 "os"
26+ goruntime "runtime"
2627 "time"
2728
2829 // +kubebuilder:scaffold:imports
8687 watchFilterValue string
8788 watchNamespace string
8889 profilerAddress string
90+ enableContentionProfiling bool
8991 kubeadmControlPlaneConcurrency int
9092 syncPeriod time.Duration
9193 restConfigQPS float32
@@ -124,6 +126,9 @@ func InitFlags(fs *pflag.FlagSet) {
124126 fs .StringVar (& profilerAddress , "profiler-address" , "" ,
125127 "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
126128
129+ fs .BoolVar (& enableContentionProfiling , "contention-profiling" , false ,
130+ "Enable block profiling, if profiler-address is set." )
131+
127132 fs .IntVar (& kubeadmControlPlaneConcurrency , "kubeadmcontrolplane-concurrency" , 10 ,
128133 "Number of kubeadm control planes to process simultaneously" )
129134
@@ -188,6 +193,10 @@ func main() {
188193 watchNamespaces = []string {watchNamespace }
189194 }
190195
196+ if profilerAddress != "" && enableContentionProfiling {
197+ goruntime .SetBlockProfileRate (1 )
198+ }
199+
191200 ctrlOptions := ctrl.Options {
192201 Scheme : scheme ,
193202 MetricsBindAddress : metricsBindAddr ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222 "flag"
2323 "fmt"
2424 "os"
25+ goruntime "runtime"
2526 "time"
2627
2728 // +kubebuilder:scaffold:imports
8687 watchNamespace string
8788 watchFilterValue string
8889 profilerAddress string
90+ enableContentionProfiling bool
8991 clusterTopologyConcurrency int
9092 clusterClassConcurrency int
9193 clusterConcurrency int
@@ -159,6 +161,9 @@ func InitFlags(fs *pflag.FlagSet) {
159161 fs .StringVar (& profilerAddress , "profiler-address" , "" ,
160162 "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
161163
164+ fs .BoolVar (& enableContentionProfiling , "contention-profiling" , false ,
165+ "Enable block profiling, if profiler-address is set." )
166+
162167 fs .IntVar (& clusterTopologyConcurrency , "clustertopology-concurrency" , 10 ,
163168 "Number of clusters to process simultaneously" )
164169
@@ -252,6 +257,10 @@ func main() {
252257 watchNamespaces = []string {watchNamespace }
253258 }
254259
260+ if profilerAddress != "" && enableContentionProfiling {
261+ goruntime .SetBlockProfileRate (1 )
262+ }
263+
255264 ctrlOptions := ctrl.Options {
256265 Scheme : scheme ,
257266 MetricsBindAddress : metricsBindAddr ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222 "flag"
2323 "fmt"
2424 "os"
25+ goruntime "runtime"
2526 "time"
2627
2728 // +kubebuilder:scaffold:imports
7374 watchNamespace string
7475 watchFilterValue string
7576 profilerAddress string
77+ enableContentionProfiling bool
7678 concurrency int
7779 syncPeriod time.Duration
7880 restConfigQPS float32
@@ -125,6 +127,9 @@ func initFlags(fs *pflag.FlagSet) {
125127 fs .StringVar (& profilerAddress , "profiler-address" , "" ,
126128 "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
127129
130+ fs .BoolVar (& enableContentionProfiling , "contention-profiling" , false ,
131+ "Enable block profiling, if profiler-address is set." )
132+
128133 fs .IntVar (& concurrency , "concurrency" , 10 ,
129134 "The number of docker machines to process simultaneously" )
130135
@@ -186,6 +191,10 @@ func main() {
186191 watchNamespaces = []string {watchNamespace }
187192 }
188193
194+ if profilerAddress != "" && enableContentionProfiling {
195+ goruntime .SetBlockProfileRate (1 )
196+ }
197+
189198 ctrlOptions := ctrl.Options {
190199 Scheme : scheme ,
191200 MetricsBindAddress : metricsBindAddr ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222 "flag"
2323 "fmt"
2424 "os"
25+ goruntime "runtime"
2526 "time"
2627
2728 "github.com/spf13/pflag"
6869 watchNamespace string
6970 watchFilterValue string
7071 profilerAddress string
72+ enableContentionProfiling bool
7173 clusterConcurrency int
7274 machineConcurrency int
7375 syncPeriod time.Duration
@@ -121,6 +123,9 @@ func InitFlags(fs *pflag.FlagSet) {
121123 fs .StringVar (& profilerAddress , "profiler-address" , "" ,
122124 "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
123125
126+ fs .BoolVar (& enableContentionProfiling , "contention-profiling" , false ,
127+ "Enable block profiling, if profiler-address is set." )
128+
124129 fs .IntVar (& clusterConcurrency , "cluster-concurrency" , 10 ,
125130 "Number of clusters to process simultaneously" )
126131
@@ -180,6 +185,10 @@ func main() {
180185 watchNamespaces = []string {watchNamespace }
181186 }
182187
188+ if profilerAddress != "" && enableContentionProfiling {
189+ goruntime .SetBlockProfileRate (1 )
190+ }
191+
183192 ctrlOptions := ctrl.Options {
184193 Scheme : scheme ,
185194 MetricsBindAddress : metricsBindAddr ,
You can’t perform that action at this time.
0 commit comments