-
Notifications
You must be signed in to change notification settings - Fork 23
CLOUDP-321076: expose prometheus metrics settings in MongoDBSearch #578
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
base: master
Are you sure you want to change the base?
Conversation
MCK 1.6.0 Release NotesNew Features
Bug Fixes
Other Changes
|
fealebenpae
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Couple of suggestions, and please fix the incorrect value in the Port field's comment in the CRD.
| Address: fmt.Sprintf("0.0.0.0:%d", search.GetMongotMetricsPort()), | ||
|
|
||
| if prometheus := search.GetPrometheus(); prometheus != nil { | ||
| port := search.GetMongotMetricsPort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should remove GetMongotMetricsPort() from the MongoDBSearch struct and implement it on the Prometheus struct so this will read something like:
if prometheus := search.GetPrometheus(); prometheus != nil {
port := prometheus.GetPort()
config.Metrics = mongot.ConfigMetrics{...}
}Same thing in buildSearchHeadlessService() above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent suggestion! Thanks!
|
|
||
| def assert_search_pod_prometheus_endpoint(mdbs: MongoDBSearch, should_be_accessible: bool, port: int = 9946): | ||
| pod_name = f"{mdbs.name}-search-0" | ||
| url = f"http://localhost:{port}/metrics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we hit http://{mdbs.name}-search-svc:{port} directly we could omit explicitly asserting properties of the Service object in assert_search_service_prometheus_port() altogether, I think. I don't know if it's worth it to maintain the distinction between "the port was configured on the Service" and "prometheus was enabled in mongot configuration" since the former is already tested in the search reconcile helper unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree 💯 I've reworked it a bit. I'm deploying a tools/bastion pod (community image like in snippets) to connect to the probe. Might seem like an overkill for now, but I wanted to take that opportunity and test this approach in practice as we're planning to get rid of the e2e pod entirely and we'll need some sort of proxy for the connectivity checks soon anyway.
3987745 to
c7e1d7c
Compare
|
|
||
| // getReleaseJsonPath searches for a specified target directory by traversing the directory tree backwards from the current working directory | ||
| func getReleaseJsonPath() (string, error) { | ||
| repositoryRootDirName := "mongodb-kubernetes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this failed tests when running from a different dir, e.g. a git worktree
| ctx, | ||
| reconcile.Request{NamespacedName: types.NamespacedName{Name: search.Name, Namespace: search.Namespace}}, | ||
| ) | ||
| expected, _ := workflow.OK().ReconcileResult() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks to the fix here it started to fail.
In order to reconcile successfully it must be always done by two steps: first reconcile is Pending (sts not ready), second time we simulate sts readiness and then it's Running. This is what checkSearchReconcileSuccessful is doing here.
c7e1d7c to
161ebd4
Compare
Co-authored-by: Yavor Georgiev <fealebenpae@users.noreply.github.com>
161ebd4 to
6fc1067
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vinilage I've aggregated all the search-related change logs for this release under one point as those were scattered randomly across release notes. We might think about adding some additional grouping per CRD for example to make it automatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new entry for this PR is the one starting from "Exposed configuration settings..."
Summary
Expose prometheus settings in
MongoDBSearchspec in a newspec.prometheusfield.spec.prometheusfield is not provided then metrics endpoint in mongot is disabled. This is a breaking change. Previously the metrics endpoing was always enabled on port 9946.spec.prometheus:field. It will enable metrics endpoint on a default port (9946). To change the port, set it inspec.prometheus.portfield.Proof of Work
Tested in unit and e2e tests.
For e2e prometheus endpoint checks were hooked into existing
e2e_search_enterprise_tls.