Skip to content

Commit

Permalink
feat(cmd): add profiling option to olm and catalog commands
Browse files Browse the repository at this point in the history
  • Loading branch information
njhale committed Jun 27, 2019
1 parent a5d1e4b commit c890e84
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
15 changes: 13 additions & 2 deletions cmd/catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import (
"time"

configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
utilclock "k8s.io/apimachinery/pkg/util/clock"
"k8s.io/client-go/tools/clientcmd"

"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/profile"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/signals"
"github.com/operator-framework/operator-lifecycle-manager/pkg/metrics"
olmversion "github.com/operator-framework/operator-lifecycle-manager/pkg/version"
Expand Down Expand Up @@ -61,6 +62,9 @@ var (

tlsCertPath = flag.String(
"tls-cert", "", "Path to use for certificate key (requires tls-key)")

profiling = flag.Bool(
"profiling", false, "serve profiling data (on port 8080)")
)

func init() {
Expand Down Expand Up @@ -114,6 +118,13 @@ func main() {
healthMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})

// Serve profiling if enabled
if *profiling {
logger.Infof("profiling enabled")
profile.RegisterHandlers(healthMux)
}

go http.ListenAndServe(":8080", healthMux)

metricsMux := http.NewServeMux()
Expand Down
13 changes: 12 additions & 1 deletion cmd/olm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
Expand All @@ -19,6 +18,8 @@ import (
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/profile"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/signals"
"github.com/operator-framework/operator-lifecycle-manager/pkg/metrics"
olmversion "github.com/operator-framework/operator-lifecycle-manager/pkg/version"
Expand Down Expand Up @@ -59,6 +60,9 @@ var (

tlsCertPath = flag.String(
"tls-cert", "", "Path to use for certificate key (requires tls-key)")

profiling = flag.Bool(
"profiling", false, "serve profiling data (on port 8080)")
)

func init() {
Expand Down Expand Up @@ -114,6 +118,13 @@ func main() {
healthMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})

// Serve profiling if enabled
if *profiling {
logger.Infof("profiling enabled")
profile.RegisterHandlers(healthMux)
}

go func() {
err := http.ListenAndServe(":8080", healthMux)
if err != nil {
Expand Down

0 comments on commit c890e84

Please sign in to comment.