Skip to content

Commit

Permalink
operator: added --pprof flag/endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime VISONNEAU <[email protected]>
  • Loading branch information
mvisonneau authored and aanm committed Feb 14, 2021
1 parent 1141308 commit 9957f5c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-operator-aws.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-operator-azure.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-operator-generic.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-operator.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions operator/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ func init() {
flags.String(operatorOption.OperatorAPIServeAddr, "localhost:9234", "Address to serve API requests")
option.BindEnv(operatorOption.OperatorAPIServeAddr)

flags.Bool(operatorOption.PProf, false, "Enable pprof debugging endpoint")
option.BindEnv(operatorOption.PProf)

flags.Bool(operatorOption.SyncK8sServices, true, "Synchronize Kubernetes services to kvstore")
option.BindEnv(operatorOption.SyncK8sServices)

Expand Down
5 changes: 5 additions & 0 deletions operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/cilium/cilium/pkg/logging/logfields"
"github.com/cilium/cilium/pkg/metrics"
"github.com/cilium/cilium/pkg/option"
"github.com/cilium/cilium/pkg/pprof"
"github.com/cilium/cilium/pkg/rand"
"github.com/cilium/cilium/pkg/rate"
"github.com/cilium/cilium/pkg/version"
Expand Down Expand Up @@ -256,6 +257,10 @@ func runOperator() {
operatorMetrics.Register()
}

if operatorOption.Config.PProf {
pprof.Enable()
}

initK8s(k8sInitDone)

capabilities := k8sversion.Capabilities()
Expand Down
7 changes: 7 additions & 0 deletions operator/option/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const (
// metrics (pass ":Port" to bind on all interfaces, "" is off).
OperatorPrometheusServeAddr = "operator-prometheus-serve-addr"

// PProf enabled pprof debugging endpoint
PProf = "pprof"

// SyncK8sServices synchronizes k8s services into the kvstore
SyncK8sServices = "synchronize-k8s-services"

Expand Down Expand Up @@ -216,6 +219,9 @@ type OperatorConfig struct {
OperatorAPIServeAddr string
OperatorPrometheusServeAddr string

// PProf enables pprof debugging endpoint
PProf bool

// SyncK8sServices synchronizes k8s services into the kvstore
SyncK8sServices bool

Expand Down Expand Up @@ -328,6 +334,7 @@ func (c *OperatorConfig) Populate() {
c.NodesGCInterval = viper.GetDuration(NodesGCInterval)
c.OperatorAPIServeAddr = viper.GetString(OperatorAPIServeAddr)
c.OperatorPrometheusServeAddr = viper.GetString(OperatorPrometheusServeAddr)
c.PProf = viper.GetBool(PProf)
c.SyncK8sServices = viper.GetBool(SyncK8sServices)
c.SyncK8sNodes = viper.GetBool(SyncK8sNodes)
c.UnmanagedPodWatcherInterval = viper.GetInt(UnmanagedPodWatcherInterval)
Expand Down

0 comments on commit 9957f5c

Please sign in to comment.