Repository navigation
SOLR-18400: Plugins screen 500s when metrics are disabled - #4803
Conversation
|
Note: the v2 metrics API ( |
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... |
|
@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): v2 endpoint (unfixed, confirms janhoy's comment): |
|
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 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? |
|
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. |
/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.
623f992 to
ab046cc
Compare
Update isDisabledFeature check to include specific URL condition. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
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? |
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.


https://issues.apache.org/jira/browse/SOLR-18400
When metrics collection is disabled, return HTTP 510 INVALID STATE
, instead of throwingIOException("No metrics found in response")` which leads to → HTTP 500 and a blank Plugins screen.