Skip to content

Commit

Permalink
chore: Simplify pprof server set up (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Khalash authored Feb 5, 2024
1 parent 94d34f5 commit 26e4631
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import (
"context"
"errors"
"flag"
"net/http"
"os"
"strings"
"sync"
"time"

"github.com/go-logr/zapr"
Expand Down Expand Up @@ -73,7 +71,6 @@ import (
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
//nolint:gosec // pprof package is required for performance analysis.
_ "net/http/pprof"
//nolint:gci // Mandatory kubebuilder imports scaffolding.
)

Expand Down Expand Up @@ -125,7 +122,6 @@ var (
metricGatewayDynamicMemoryRequest string

enableWebhook bool
mutex sync.Mutex
)

const (
Expand Down Expand Up @@ -281,25 +277,12 @@ func main() {
}
}()

go func() {
server := &http.Server{
Addr: ":6060",
ReadHeaderTimeout: 10 * time.Second,
}

err := server.ListenAndServe()
if err != nil {
mutex.Lock()
setupLog.Error(err, "Cannot start pprof server")
mutex.Unlock()
}
}()

syncPeriod := 1 * time.Minute
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{BindAddress: ":8080"},
HealthProbeBindAddress: ":8081",
PprofBindAddress: ":6060",
LeaderElection: true,
LeaderElectionNamespace: telemetryNamespace,
LeaderElectionID: "cdd7ef0b.kyma-project.io",
Expand All @@ -312,7 +295,6 @@ func main() {

// The operator handles various resource that are namespace-scoped, and additionally some resources that are cluster-scoped (clusterroles, clusterrolebindings, etc.).
// For namespace-scoped resources we want to restrict the operator permissions to only fetch resources from a given namespace.

ByObject: map[client.Object]cache.ByObject{
&appsv1.Deployment{}: {Field: setNamespaceFieldSelector()},
&appsv1.ReplicaSet{}: {Field: setNamespaceFieldSelector()},
Expand Down

0 comments on commit 26e4631

Please sign in to comment.