Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 all: Add flags to enable block profiling #8934

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
_ "net/http/pprof"
"os"
goruntime "runtime"
"time"

// +kubebuilder:scaffold:imports
Expand Down Expand Up @@ -81,6 +82,7 @@ var (
watchFilterValue string
watchNamespace string
profilerAddress string
enableContentionProfiling bool
clusterConcurrency int
kubeadmConfigConcurrency int
syncPeriod time.Duration
Expand Down Expand Up @@ -119,6 +121,9 @@ func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
fabriziopandini marked this conversation as resolved.
Show resolved Hide resolved
"Enable block profiling, if profiler-address is set.")

fs.IntVar(&clusterConcurrency, "cluster-concurrency", 10,
"Number of clusters to process simultaneously")

Expand Down Expand Up @@ -184,6 +189,10 @@ func main() {
watchNamespaces = []string{watchNamespace}
}

if profilerAddress != "" && enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

ctrlOptions := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
Expand Down
9 changes: 9 additions & 0 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
_ "net/http/pprof"
"os"
goruntime "runtime"
"time"

// +kubebuilder:scaffold:imports
Expand Down Expand Up @@ -86,6 +87,7 @@ var (
watchFilterValue string
watchNamespace string
profilerAddress string
enableContentionProfiling bool
kubeadmControlPlaneConcurrency int
syncPeriod time.Duration
restConfigQPS float32
Expand Down Expand Up @@ -124,6 +126,9 @@ func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
"Enable block profiling, if profiler-address is set.")

fs.IntVar(&kubeadmControlPlaneConcurrency, "kubeadmcontrolplane-concurrency", 10,
"Number of kubeadm control planes to process simultaneously")

Expand Down Expand Up @@ -188,6 +193,10 @@ func main() {
watchNamespaces = []string{watchNamespace}
}

if profilerAddress != "" && enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

ctrlOptions := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
Expand Down
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"flag"
"fmt"
"os"
goruntime "runtime"
"time"

// +kubebuilder:scaffold:imports
Expand Down Expand Up @@ -86,6 +87,7 @@ var (
watchNamespace string
watchFilterValue string
profilerAddress string
enableContentionProfiling bool
clusterTopologyConcurrency int
clusterClassConcurrency int
clusterConcurrency int
Expand Down Expand Up @@ -159,6 +161,9 @@ func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
"Enable block profiling, if profiler-address is set.")

fs.IntVar(&clusterTopologyConcurrency, "clustertopology-concurrency", 10,
"Number of clusters to process simultaneously")

Expand Down Expand Up @@ -252,6 +257,10 @@ func main() {
watchNamespaces = []string{watchNamespace}
}

if profilerAddress != "" && enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

ctrlOptions := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
Expand Down
9 changes: 9 additions & 0 deletions test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"flag"
"fmt"
"os"
goruntime "runtime"
"time"

// +kubebuilder:scaffold:imports
Expand Down Expand Up @@ -73,6 +74,7 @@ var (
watchNamespace string
watchFilterValue string
profilerAddress string
enableContentionProfiling bool
concurrency int
syncPeriod time.Duration
restConfigQPS float32
Expand Down Expand Up @@ -125,6 +127,9 @@ func initFlags(fs *pflag.FlagSet) {
fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
"Enable block profiling, if profiler-address is set.")

fs.IntVar(&concurrency, "concurrency", 10,
"The number of docker machines to process simultaneously")

Expand Down Expand Up @@ -186,6 +191,10 @@ func main() {
watchNamespaces = []string{watchNamespace}
}

if profilerAddress != "" && enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

ctrlOptions := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
Expand Down
9 changes: 9 additions & 0 deletions test/infrastructure/inmemory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"flag"
"fmt"
"os"
goruntime "runtime"
"time"

"github.com/spf13/pflag"
Expand Down Expand Up @@ -68,6 +69,7 @@ var (
watchNamespace string
watchFilterValue string
profilerAddress string
enableContentionProfiling bool
clusterConcurrency int
machineConcurrency int
syncPeriod time.Duration
Expand Down Expand Up @@ -121,6 +123,9 @@ func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
"Enable block profiling, if profiler-address is set.")

fs.IntVar(&clusterConcurrency, "cluster-concurrency", 10,
"Number of clusters to process simultaneously")

Expand Down Expand Up @@ -180,6 +185,10 @@ func main() {
watchNamespaces = []string{watchNamespace}
}

if profilerAddress != "" && enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

ctrlOptions := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
Expand Down