diff --git a/changelog/unreleased/SOLR-18520-uninstall-bug.yml b/changelog/unreleased/SOLR-18520-uninstall-bug.yml new file mode 100644 index 000000000000..6e66dcb25cb3 --- /dev/null +++ b/changelog/unreleased/SOLR-18520-uninstall-bug.yml @@ -0,0 +1,9 @@ +title: + Package Uninstall should work in absence of clusterprops.json file +type: fixed +authors: + - name: Jalaz Kumar + nick: jaykay12 +links: + - name: SOLR-18520 + url: https://issues.apache.org/jira/browse/SOLR-18520 diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java index b8c38274f8d1..e344f8ec35d8 100644 --- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java +++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java @@ -42,6 +42,7 @@ import org.apache.solr.cli.SolrCLI; import org.apache.solr.cli.ToolRuntime; import org.apache.solr.client.api.util.SolrVersion; +import org.apache.solr.client.solrj.RemoteSolrException; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -154,7 +155,7 @@ public void uninstall(String packageName, String version) del.pkg = packageName; V2Request req = - new V2Request.Builder(PackageUtils.PACKAGE_PATH) + new V2Request.Builder("/cluster/package") .forceV2(true) .withMethod(SolrRequest.METHOD.POST) .withPayload(Map.of("delete", del)) @@ -278,18 +279,18 @@ public Map getPackagesDeployedAsClusterLevelPlugins Map packageVersions = new HashMap<>(); // map of package name to multiple values of pluginMeta(Map) Map> packagePlugins = new HashMap<>(); - Object pluginsValue; + Object pluginsValue = null; try { NamedList response = solrClient.request( new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH)); Integer statusCode = (Integer) response._get(List.of("responseHeader", "status"), null); - if (statusCode == null || statusCode == ErrorCode.NOT_FOUND.code) { - // Cluster props doesn't exist, that means there are no cluster level plugins installed. - pluginsValue = null; - } else { + if (statusCode != null && statusCode != ErrorCode.NOT_FOUND.code) { + // Cluster props exists, that means there are cluster level plugins installed. pluginsValue = response.get(ContainerPluginsApi.PLUGIN); } + } catch (RemoteSolrException ex) { + log.debug("Unable to fetch clusterprops for package plugins", ex); } catch (SolrServerException | IOException ex) { throw new SolrException(ErrorCode.SERVER_ERROR, ex); }