Repository navigation
SOLR-18400: Plugins screen 500s when metrics are disabled #4803
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
Merged
janhoy
merged 7 commits into
apache:main
from
janhoy:SOLR-18400-plugins-metrics-disabled
Oct 8, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
acc2332
SOLR-18400: Plugins screen 500s when metrics are disabled
janhoy 42bdce1
SOLR-18400: Replace cluster-based test with unit test in TestPromethe…
janhoy 7675a78
SOLR-18400: Address review comments
janhoy b8b5538
SOLR-18400: Remove changelog entry, not needed for a minor fix
janhoy ab046cc
SOLR-18400: Answer HTTP 510 when metrics collection is disabled
janhoy 9735d48
Modify isDisabledFeature condition for metrics URL
janhoy d0cd630
SOLR-18400: Browser test for the Plugins screen with metrics disabled
janhoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
changelog/unreleased/SOLR-18400-plugins-metrics-disabled.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| title: > | ||
| The metrics endpoints now answer HTTP 510 when metrics collection is disabled in solr.xml, | ||
| on both the v1 and v2 API. The v1 API used to return HTTP 500, which made the Admin UI | ||
| Plugins / Stats screen render blank. It now explains that metrics are disabled. | ||
| type: fixed | ||
| authors: | ||
| - name: Jan Høydahl | ||
| - name: Eric Pugh | ||
| links: | ||
| - name: SOLR-18400 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18400 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
solr/core/src/test/org/apache/solr/handler/admin/MetricsDisabledTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.solr.handler.admin; | ||
|
|
||
| import org.apache.solr.client.solrj.request.MetricsRequest; | ||
| import org.apache.solr.client.solrj.response.InputStreamResponseParser; | ||
| import org.apache.solr.cloud.SolrCloudTestCase; | ||
| import org.apache.solr.common.SolrException; | ||
| import org.apache.solr.common.params.CommonParams; | ||
| import org.apache.solr.common.params.SolrParams; | ||
| import org.apache.solr.common.util.NamedList; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * Both the v1 {@code /admin/metrics} and the v2 {@code /api/metrics} endpoint answer HTTP 510 when | ||
| * metrics collection is switched off in solr.xml. | ||
| */ | ||
| public class MetricsDisabledTest extends SolrCloudTestCase { | ||
|
|
||
| private static final String METRICS_V2_PATH = "/metrics"; | ||
|
|
||
| @BeforeClass | ||
| public static void setupCluster() throws Exception { | ||
| // MiniSolrCloudCluster's default solr.xml has <metrics enabled="false"> | ||
| configureCluster(1).configure(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testV1MetricsDisabled() throws Exception { | ||
| assertMetricsDisabled(CommonParams.METRICS_PATH); | ||
| } | ||
|
|
||
| @Test | ||
| public void testV2MetricsDisabled() throws Exception { | ||
| assertMetricsDisabled(METRICS_V2_PATH); | ||
| } | ||
|
|
||
| private static void assertMetricsDisabled(String path) throws Exception { | ||
| var req = new MetricsRequest(path, SolrParams.of(CommonParams.WT, "prometheus")); | ||
|
|
||
| NamedList<Object> resp = cluster.getSolrClient().request(req); | ||
| String body = InputStreamResponseParser.consumeResponseToString(resp); | ||
|
|
||
| assertEquals( | ||
| "Expected HTTP 510 from " + path, | ||
| SolrException.ErrorCode.INVALID_STATE.code, | ||
| (int) (Integer) resp.get(InputStreamResponseParser.HTTP_STATUS_KEY)); | ||
| assertTrue(body, body.contains("Metrics collection is disabled")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
solr/webapp/src/test/org/apache/solr/webapp/AdminUiMetricsDisabledStandaloneTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.solr.webapp; | ||
|
|
||
| import java.nio.file.Path; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import org.openqa.selenium.By; | ||
|
|
||
| /** | ||
| * SOLR-18400: the Plugins screen on a node with metrics collection switched off in solr.xml. The | ||
| * metrics endpoint answers HTTP 510 there, which the screen must turn into an explanation rather | ||
| * than a blank page or the global error banner. | ||
| */ | ||
| public class AdminUiMetricsDisabledStandaloneTest extends AdminUiStandaloneTestBase { | ||
|
|
||
| private static final String CORE = "collection1"; | ||
|
|
||
| @BeforeClass | ||
| public static void startStandaloneNode() throws Exception { | ||
| // the base class turned metrics on for the UI screens; this suite is about them being off. | ||
| // Must come before the node starts, and is restored after the class with the other properties | ||
| System.setProperty("metricsEnabled", "false"); | ||
| Path home = buildStandaloneHome(CORE); | ||
| standaloneJetty = startStandaloneJetty(home); | ||
| baseUrl = standaloneJetty.getBaseUrl().toString(); | ||
| assertFalse( | ||
| "fixture node should have metrics disabled", | ||
| standaloneJetty.getCoreContainer().getConfig().getMetricsConfig().isEnabled()); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void stopStandaloneNode() throws Exception { | ||
| if (standaloneJetty != null) { | ||
| standaloneJetty.stop(); | ||
| standaloneJetty = null; | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testPluginsScreenExplainsDisabledMetrics() { | ||
| openPage(CORE + "/plugins", By.id("plugins")); | ||
|
|
||
| String message = waitForText(By.cssSelector("#plugins .message-container .message")); | ||
| assertTrue(message, message.contains("Metrics collection is disabled")); | ||
|
|
||
| // no plugin categories or entries, as there is no metrics data to build them from | ||
| assertTrue(driver.findElements(By.cssSelector("#plugins #navigation a[rel]")).isEmpty()); | ||
| assertTrue(driver.findElements(By.cssSelector("#plugins #frame li.entry")).isEmpty()); | ||
|
|
||
| // the 510 is handled by the screen itself; the global error banner must stay away | ||
| assertTrue( | ||
| "global error banner should not show for a disabled feature", | ||
| driver.findElements(By.id("http-exception")).isEmpty()); | ||
|
|
||
| // Chrome reports the failed XHR itself at SEVERE level; everything else must be clean | ||
| assertNoSevereConsoleErrors("510"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.