Skip to content

Commit

Permalink
enable Pprof with option --enable-pprof (#245)
Browse files Browse the repository at this point in the history
* rename to connectExternalBGPPeers

* enable pprof for debug purpose
  • Loading branch information
murali-reddy committed Dec 12, 2017
1 parent fcd1a1a commit c4830aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func newGlobalPeers(ips []net.IP, asns []uint32, passwords []string) (
return peers, nil
}

func connectToPeers(server *gobgp.BgpServer, peerConfigs []*config.NeighborConfig, bgpGracefulRestart bool, peerMultihopTtl uint8) error {
func connectToExternalBGPPeers(server *gobgp.BgpServer, peerConfigs []*config.NeighborConfig, bgpGracefulRestart bool, peerMultihopTtl uint8) error {
for _, peerConfig := range peerConfigs {
n := &config.Neighbor{
Config: *peerConfig,
Expand Down Expand Up @@ -1332,7 +1332,7 @@ func (nrc *NetworkRoutingController) startBgpServer() error {
}

if len(nrc.globalPeerRouters) != 0 {
err := connectToPeers(nrc.bgpServer, nrc.globalPeerRouters, nrc.bgpGracefulRestart, nrc.peerMultihopTtl)
err := connectToExternalBGPPeers(nrc.bgpServer, nrc.globalPeerRouters, nrc.bgpGracefulRestart, nrc.peerMultihopTtl)
if err != nil {
nrc.bgpServer.Stop()
return fmt.Errorf("Failed to peer with Global Peer Router(s): %s",
Expand Down
3 changes: 3 additions & 0 deletions app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type KubeRouterConfig struct {
NodePortBindOnAllIp bool
EnableOverlay bool
PeerPasswords []string
EnablePprof bool
// FullMeshPassword string
}

Expand Down Expand Up @@ -106,6 +107,8 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
"When set to false no tunneling is used and routing infrastrcture is expected to route traffic for pod-to-pod networking across nodes in different subnets")
fs.StringSliceVar(&s.PeerPasswords, "peer-router-passwords", s.PeerPasswords,
"Password for authenticating against the BGP peer defined with \"--peer-router-ips\".")
fs.BoolVar(&s.EnablePprof, "enable-pprof", false,
"Enables pprof for debugging performance and memory leak issues.")
// fs.StringVar(&s.FullMeshPassword, "nodes-full-mesh-password", s.FullMeshPassword,
// "Password that cluster-node BGP servers will use to authenticate one another when \"--nodes-full-mesh\" is set.")
}
10 changes: 9 additions & 1 deletion kube-router.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"flag"
"fmt"
"net/http"
"os"

"flag"
_ "net/http/pprof"

"github.com/cloudnativelabs/kube-router/app"
"github.com/cloudnativelabs/kube-router/app/options"
Expand Down Expand Up @@ -44,6 +46,12 @@ func main() {
os.Exit(1)
}

if config.EnablePprof {
go func() {
fmt.Fprintf(os.Stdout, http.ListenAndServe("0.0.0.0:6060", nil).Error())
}()
}

err = kubeRouter.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to run kube-router: %v\n", err)
Expand Down

0 comments on commit c4830aa

Please sign in to comment.