You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2019/12/18 14:55:23 UTC

[lucene-solr] branch branch_8x updated: SOLR-13983: remove or replace process execution in SystemInfoHandler

This is an automated email from the ASF dual-hosted git repository.

rmuir pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 8c14015  SOLR-13983: remove or replace process execution in SystemInfoHandler
8c14015 is described below

commit 8c14015e52af2568aaefbf6fb4c6e8ad01a6a8fe
Author: Robert Muir <rm...@apache.org>
AuthorDate: Wed Dec 18 09:03:07 2019 -0500

    SOLR-13983: remove or replace process execution in SystemInfoHandler
---
 solr/CHANGES.txt                                   |  3 ++
 .../solr/handler/admin/SystemInfoHandler.java      | 45 ----------------------
 solr/webapp/web/js/angular/controllers/index.js    |  8 +---
 solr/webapp/web/partials/index.html                |  2 +-
 4 files changed, 5 insertions(+), 53 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7949a5f..06bad89 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -36,6 +36,9 @@ Upgrade Notes
 * SOLR-14092: BlockJoinFacetComponent is marked for deprecation and will be removed in 9.0.
   Users are encouraged to migrate to uniqueBlock() in JSON Facet API.  (Mikhail Khludnev)
 
+* SOLR-13983: Process execution is removed from SystemInfoHandler. A best-effort attempt to
+  execute "uname -a" and "uptime" on non-Windows platforms is no longer made. (rmuir)
+
 New Features
 ---------------------
 (No changes)
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
index 5dcf64c..e27624c 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
@@ -18,14 +18,11 @@ package org.apache.solr.handler.admin;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.lang.invoke.MethodHandles;
 import java.lang.management.ManagementFactory;
 import java.lang.management.OperatingSystemMXBean;
 import java.lang.management.RuntimeMXBean;
 import java.net.InetAddress;
-import java.nio.charset.Charset;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Date;
@@ -34,9 +31,7 @@ import java.util.List;
 import java.util.Locale;
 
 import com.codahale.metrics.Gauge;
-import org.apache.commons.io.IOUtils;
 import org.apache.lucene.LucenePackage;
-import org.apache.lucene.util.Constants;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
@@ -227,50 +222,10 @@ public class SystemInfoHandler extends RequestHandlerBase
       }
     });
 
-    // Try some command line things:
-    try { 
-      if (!Constants.WINDOWS) {
-        info.add( "uname",  execute( "uname -a" ) );
-        info.add( "uptime", execute( "uptime" ) );
-      }
-    } catch( Exception ex ) {
-      log.warn("Unable to execute command line tools to get operating system properties.", ex);
-    } 
     return info;
   }
   
   /**
-   * Utility function to execute a function
-   */
-  private static String execute( String cmd )
-  {
-    InputStream in = null;
-    Process process = null;
-    
-    try {
-      process = Runtime.getRuntime().exec(cmd);
-      in = process.getInputStream();
-      // use default charset from locale here, because the command invoked also uses the default locale:
-      return IOUtils.toString(new InputStreamReader(in, Charset.defaultCharset()));
-    } catch( Exception ex ) {
-      // ignore - log.warn("Error executing command", ex);
-      return "(error executing: " + cmd + ")";
-    } catch (Error err) {
-      if (err.getMessage() != null && (err.getMessage().contains("posix_spawn") || err.getMessage().contains("UNIXProcess"))) {
-        log.warn("Error forking command due to JVM locale bug (see https://issues.apache.org/jira/browse/SOLR-6387): " + err.getMessage());
-        return "(error executing: " + cmd + ")";
-      }
-      throw err;
-    } finally {
-      if (process != null) {
-        IOUtils.closeQuietly( process.getOutputStream() );
-        IOUtils.closeQuietly( process.getInputStream() );
-        IOUtils.closeQuietly( process.getErrorStream() );
-      }
-    }
-  }
-  
-  /**
    * Get JVM Info - including memory info
    */
   public static SimpleOrderedMap<Object> getJvmInfo()
diff --git a/solr/webapp/web/js/angular/controllers/index.js b/solr/webapp/web/js/angular/controllers/index.js
index f7ce5a8..34299a7 100644
--- a/solr/webapp/web/js/angular/controllers/index.js
+++ b/solr/webapp/web/js/angular/controllers/index.js
@@ -22,13 +22,7 @@ solrAdminApp.controller('IndexController', function($scope, System, Cores, Const
       $scope.system = data;
 
       // load average
-      var load_average = ( data.system.uptime || '' ).match( /load averages?: (\d+[.,]\d\d),? (\d+[.,]\d\d),? (\d+[.,]\d\d)/ );
-      if (load_average) {
-        for (var i=0;i<2;i++) {
-          load_average[i]=load_average[i].replace(",","."); // for European users
-        }
-        $scope.load_average = load_average.slice(1);
-      }
+      $scope.load_average = data.system.systemLoadAverage.toFixed(2);
 
       // physical memory
       var memoryMax = parse_memory_value(data.system.totalPhysicalMemorySize);
diff --git a/solr/webapp/web/partials/index.html b/solr/webapp/web/partials/index.html
index b9e6a90..8fe0b66 100644
--- a/solr/webapp/web/partials/index.html
+++ b/solr/webapp/web/partials/index.html
@@ -106,7 +106,7 @@ limitations under the License.
       <div class="block" id="system">
 
           <h2><span>System</span>
-    <small class="bar-desc">{{load_average[0]}} {{load_average[1]}} {{load_average[2]}}</small>
+    <small class="bar-desc">{{load_average}}</small>
     </h2>
           <a class="reload" ng-click="reload()"><span>reload</span></a>