Skip to content

Commit ad965df

Browse files
authored
Merge pull request #5674 from sbueringer/pr-capd-add-profiler-address-flag
✨ CAPD: Add profiler-address flag
2 parents 536feb4 + be38742 commit ad965df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/infrastructure/docker/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"flag"
2222
"math/rand"
23+
"net/http"
2324
"os"
2425
"time"
2526

@@ -55,6 +56,7 @@ var (
5556
// flags.
5657
metricsBindAddr string
5758
enableLeaderElection bool
59+
profilerAddress string
5860
syncPeriod time.Duration
5961
concurrency int
6062
healthAddr string
@@ -84,6 +86,8 @@ func initFlags(fs *pflag.FlagSet) {
8486
"The number of docker machines to process simultaneously")
8587
fs.BoolVar(&enableLeaderElection, "leader-elect", false,
8688
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
89+
fs.StringVar(&profilerAddress, "profiler-address", "",
90+
"Bind address to expose the pprof profiler (e.g. localhost:6060)")
8791
fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute,
8892
"The minimum interval at which watched resources are reconciled (e.g. 15m)")
8993
fs.StringVar(&healthAddr, "health-addr", ":9440",
@@ -106,6 +110,13 @@ func main() {
106110

107111
ctrl.SetLogger(klogr.New())
108112

113+
if profilerAddress != "" {
114+
klog.Infof("Profiler listening for requests at %s", profilerAddress)
115+
go func() {
116+
klog.Info(http.ListenAndServe(profilerAddress, nil))
117+
}()
118+
}
119+
109120
restConfig := ctrl.GetConfigOrDie()
110121
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent("cluster-api-docker-controller-manager")
111122
mgr, err := ctrl.NewManager(restConfig, ctrl.Options{

0 commit comments

Comments
 (0)