Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metrics): remove resources that aren't updated #637

Merged
merged 2 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"strings"
"time"

"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"

"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog"
"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 @@ -45,6 +47,10 @@ var (
version = flag.Bool("version", false, "displays olm version")
)

func init() {
metrics.RegisterCatalog()
}

func main() {
stopCh := signals.SetupSignalHandler()

Expand Down Expand Up @@ -87,6 +93,10 @@ func main() {
log.Panicf("error configuring operator: %s", err.Error())
}

http.Handle("/metrics", promhttp.Handler())
go http.ListenAndServe(":8081", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is serving a nil handler - did you mean to serve metrics on this port?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This port change was intentional, though perhaps it's not the best? OLM serves healthz from port 8080, so I wanted the metrics ports to be consistent.


_, done := catalogOperator.Run(stopCh)
<-done
}

11 changes: 5 additions & 6 deletions cmd/olm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"

Expand Down Expand Up @@ -45,7 +45,7 @@ var (
)

func init() {
metrics.Register()
metrics.RegisterOLM()
}

// main function - entrypoint to OLM operator
Expand Down Expand Up @@ -100,12 +100,11 @@ func main() {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
// TODO: both of the following require vendor updates (add k8s.io/apiserver and update prometheus)
//healthz.InstallHandler(mux) //(less code)
//mux.Handle("/metrics", promhttp.Handler()) //other form is deprecated
http.Handle("/metrics", prometheus.Handler())
go http.ListenAndServe(":8080", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar issue here, though this has clearly been here a while

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comments, I'm nearly certain I've confirmed that healthz was being served correctly.


http.Handle("/metrics", promhttp.Handler())
go http.ListenAndServe(":8081", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also serving a nil handler here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, nil is intentional, it should use the "DefaultServeMux".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha - didn't know about DefaultServeMux - I think go didn't have a muxer last time I used http? 😂


_, done := operator.Run(stopCh)
<-done
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ require (
k8s.io/klog v0.1.0 // indirect
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
k8s.io/kubernetes v1.11.7-beta.0.0.20190108024450-5a0d4e5b8d31
k8s.io/kubernetes v1.11.7-beta.0.0.20190112090204-23cf8fe78f62
)
53 changes: 50 additions & 3 deletions go.sum

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,18 @@ var (
CSVUpgradeCount = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "csv_upgrade_count",
Help: "Monotonic count of catalog sources",
Help: "Monotonic count of CSV upgrades",
},
)
)

func Register() {
func RegisterOLM() {
prometheus.MustRegister(csvCount)
prometheus.MustRegister(CSVUpgradeCount)
}

func RegisterCatalog() {
prometheus.MustRegister(installPlanCount)
prometheus.MustRegister(subscriptionCount)
prometheus.MustRegister(catalogSourceCount)
prometheus.MustRegister(CSVUpgradeCount)
}

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

Loading