Skip to content

SOLR-18400: Plugins screen 500s when metrics are disabled - #4803

Merged
janhoy merged 7 commits into
apache:mainfrom
janhoy:SOLR-18400-plugins-metrics-disabled
Oct 8, 2026
Merged

janhoy merged 7 commits into
apache:mainfrom
janhoy:SOLR-18400-plugins-metrics-disabled

Conversation

@janhoy

@janhoy janhoy commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-18400

When metrics collection is disabled, return HTTP 510 INVALID STATE, instead of throwing IOException("No metrics found in response")` which leads to → HTTP 500 and a blank Plugins screen.

This comment was marked as outdated.

@janhoy

janhoy commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Note: the v2 metrics API (GetMetrics) still throws a 510 INVALID_STATE error when metrics collection is disabled, so v1 and v2 now behave differently (v1 returns 200 with a # metrics collection is disabled comment). I left v2 as-is since this PR targets the v1 endpoint the Admin UI uses, but we may want to align v2 with the same graceful behavior in a follow-up.

@janhoy
janhoy marked this pull request as ready for review August 23, 2026 19:32
@epugh

epugh commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Note: the v2 metrics API (GetMetrics) still throws a 510 INVALID_STATE error when metrics collection is disabled, so v1 and v2 now behave differently (v1 returns 200 with a # metrics collection is disabled comment). I left v2 as-is since this PR targets the v1 endpoint the Admin UI uses, but we may want to align v2 with the same graceful behavior in a follow-up.

It would make life easier when we move if V2 did the same as V1... One reason I'm axinous to get us to V2 everywhere we can is that we've seen this pattern of fixes making it to V1 when we also have V2, and then it falls behind...

@epugh

epugh commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

@janhoy I think this was very close, so I updated it from main. I am also responding to a copilot item!

One question, are you suggesting that the 501 is a nicer way of handling this situation versus the current string matching approach? If so, I am also wondering if you are suggesting that we look at lots of apis through the lens of "this is a good time to throw a 501 error" and maybe make the a consistent pattern in our V2 apis? Or am I reading too much into this.

Lastly, I wonder how far our V2 GetMetrics is from being usable int eh admin ui instead of hte v1?

Backend (v1 endpoint):

curl http://localhost:8987/solr/admin/metrics?wt=prometheus
→ HTTP 200
# metrics collection is disabled
# EOF

v2 endpoint (unfixed, confirms janhoy's comment):

curl -H "Accept: text/plain; version=0.0.4" http://localhost:8987/api/metrics
→ HTTP 510, {"error":{"code":510,"msg":"Metrics collection is disabled"}}

@epugh epugh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@janhoy

janhoy commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

The 510 code used by v2 looks a bit off, although I understand the intent behind it, it is better than a 503 which could signal that the entire Solr node is unavailable.

Prometheus scraping an endpoint will interpret any non-200 code as "solr scrape target unavailable" and flag it as DOWN. A 200-code with empty response will be interpreted as "solr scrape target functioning, but no data" and flag it as "UP".

You can argue both ways. But agree v1 and v2 shuold probably be aligned. I'm not opposed to instead align v1 with HTTP 510 and adapt frontend to detect this as a "metrics disabled" signal instead of text parsing?

@janhoy

janhoy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

I think I like HTTP 510 better in general, so I vote for having both v1 and v2 APIs err with HTTP 510 when metrics are disabled. And adapt frontend to cope.

janhoy and others added 5 commits October 7, 2026 14:46
/admin/metrics now returns a valid Prometheus response with an explanatory
comment instead of a 500 when metrics collection is disabled, and the
Plugins screen shows a message instead of a blank page.
- Always append the OpenMetrics EOF marker to the disabled-metrics
  comment response (harmless in Prometheus format)
- Correct the Plugins screen message to reference the <metrics enabled>
  setting in solr.xml; metricsEnabled is not a real production property
The v1 /admin/metrics endpoint returned HTTP 500 "No metrics found in
response" when metrics collection was switched off in solr.xml, leaving
the Admin UI Plugins / Stats screen blank. The v2 /api/metrics endpoint
already answered HTTP 510 INVALID_STATE for the same condition.

Align v1 with v2: MetricsHandler throws INVALID_STATE rather than adding
an "error" entry to the response, so both API generations behave the
same. The Plugins screen now keys off the 510 instead of matching text
in the body, and the global error banner no longer fires for 510 since
the requesting screen explains the condition in place.

Adds MetricsDisabledTest covering both the v1 and the v2 endpoint, and
documents the response in the Metrics Reporting ref guide page.
@janhoy
janhoy force-pushed the SOLR-18400-plugins-metrics-disabled branch from 623f992 to ab046cc Compare October 7, 2026 13:01
@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed cat:search labels Oct 7, 2026
@janhoy
janhoy requested review from epugh and a lite review from Copilot October 7, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Restrict global HTTP 510 suppression to the metrics request and add Admin UI coverage for the disabled-metrics path.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
Resolved since last review (2)

Comment thread solr/webapp/web/js/angular/app.js Outdated
Comment thread solr/webapp/web/js/angular/controllers/plugins.js
Update isDisabledFeature check to include specific URL condition.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@epugh

epugh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Interestingly I was just poiking at the SQL UI in the admin tool, if you don't enable the module you get an error when you run a sql query. I modified it to catch the classcast exception "no SQLHandler found" and then show a nice message about enabling the module. I first thought hoguht "hey, can I consult which plugins/endpoints are avialable via v2 apis" and was going to see if the /sql existed or not. BUt that API doesn't exist. SO I went with the narrower fix.

I wonder if we should return 510 instead of a classcast exception if you hit /sql and it can't load?

@epugh epugh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

The existing Admin UI suites all run with metrics collection on, so the
new HTTP 510 handling in the Plugins controller and the banner exemption
in the http interceptor had no browser coverage.

Adds a standalone-node suite that starts Solr with metrics switched off
and asserts the screen renders the explanatory message, lists no plugin
categories, and raises no global error banner. Verified to fail against
both the controller and the interceptor with their fixes reverted.
@janhoy janhoy added this to the 10.x milestone Oct 8, 2026
@janhoy
janhoy merged commit e34067a into apache:main Oct 8, 2026
6 checks passed
@janhoy
janhoy deleted the SOLR-18400-plugins-metrics-disabled branch October 8, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

admin-ui documentation Improvements or additions to documentation no-changelog tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants