You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ab...@apache.org on 2021/04/26 15:51:10 UTC

[solr] branch main updated: SOLR-15019: Remove support for (unsecure) env variables until it's needed.

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

ab pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new d79b19a  SOLR-15019: Remove support for (unsecure) env variables until it's needed.
d79b19a is described below

commit d79b19aeda8b7d69ebc6e3e4a99e1a8b1aea1f5d
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Mon Apr 26 17:50:03 2021 +0200

    SOLR-15019: Remove support for (unsecure) env variables until it's needed.
---
 .../apache/solr/cluster/placement/AttributeFetcher.java |  6 ------
 .../apache/solr/cluster/placement/AttributeValues.java  |  5 -----
 .../cluster/placement/impl/AttributeFetcherImpl.java    | 10 ----------
 .../cluster/placement/impl/AttributeValuesImpl.java     |  9 ---------
 .../solr/cluster/placement/AttributeFetcherForTest.java |  5 -----
 .../placement/impl/PlacementPluginIntegrationTest.java  | 17 -----------------
 .../client/solrj/impl/SolrClientNodeStateProvider.java  |  3 ---
 .../apache/solr/common/cloud/rule/ImplicitSnitch.java   |  1 -
 8 files changed, 56 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java b/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java
index ae2afc7..2d9e581 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java
@@ -33,12 +33,6 @@ public interface AttributeFetcher {
   AttributeFetcher requestNodeSystemProperty(String name);
 
   /**
-   * Request an environment variable on each node. To get the value use {@link AttributeValues#getEnvironmentVariable(Node, String)}
-   * @param name environment property name
-   */
-  AttributeFetcher requestNodeEnvironmentVariable(String name);
-
-  /**
    * Request a node metric from each node. To get the value use {@link AttributeValues#getNodeMetric(Node, NodeMetric)}
    * @param metric metric to retrieve (see {@link NodeMetric})
    */
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/AttributeValues.java b/solr/core/src/java/org/apache/solr/cluster/placement/AttributeValues.java
index b0e7e45..a3666cc 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/AttributeValues.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/AttributeValues.java
@@ -28,11 +28,6 @@ public interface AttributeValues {
   Optional<String> getSystemProperty(Node node, String name);
 
   /**
-   * For the given node: environment variable value
-   */
-  Optional<String> getEnvironmentVariable(Node node, String name);
-
-  /**
    * For the given node: metric identified by an instance of {@link NodeMetric}
    */
   <T> Optional<T> getNodeMetric(Node node, NodeMetric<T> metric);
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
index af8e72e..0dcac3b 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
@@ -65,12 +65,6 @@ public class AttributeFetcherImpl implements AttributeFetcher {
   }
 
   @Override
-  public AttributeFetcher requestNodeEnvironmentVariable(String name) {
-    requestedNodeSystemSnitchTags.add(getSystemEnvSnitchTag(name));
-    return this;
-  }
-
-  @Override
   public AttributeFetcher requestNodeMetric(NodeMetric<?> metric) {
     requestedNodeMetricSnitchTags.add(metric);
     return this;
@@ -214,8 +208,4 @@ public class AttributeFetcherImpl implements AttributeFetcher {
   public static String getSystemPropertySnitchTag(String name) {
     return ImplicitSnitch.SYSPROP + name;
   }
-
-  public static String getSystemEnvSnitchTag(String name) {
-    return ImplicitSnitch.SYSENV + name;
-  }
 }
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java
index 873bd3d..5861b87 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java
@@ -54,15 +54,6 @@ public class AttributeValuesImpl implements AttributeValues {
   }
 
   @Override
-  public Optional<String> getEnvironmentVariable(Node node, String name) {
-    Map<Node, String> nodeToValue = systemSnitchToNodeToValue.get(AttributeFetcherImpl.getSystemEnvSnitchTag(name));
-    if (nodeToValue == null) {
-      return Optional.empty();
-    }
-    return Optional.ofNullable(nodeToValue.get(node));
-  }
-
-  @Override
   @SuppressWarnings("unchecked")
   public <T> Optional<T> getNodeMetric(Node node, NodeMetric<T> metric) {
     Map<Node, Object> nodeToValue = metricSnitchToNodeToValue.get(metric);
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java
index bcc300b..8553ee0 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java
@@ -36,11 +36,6 @@ public class AttributeFetcherForTest implements AttributeFetcher {
   }
 
   @Override
-  public AttributeFetcher requestNodeEnvironmentVariable(String name) {
-    throw new UnsupportedOperationException("Not yet implemented...");
-  }
-
-  @Override
   public AttributeFetcher requestNodeMetric(NodeMetric<?> metric) {
     return this;
   }
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
index f2140e7..93003a1 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
@@ -360,18 +360,6 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
     AttributeFetcher attributeFetcher = new AttributeFetcherImpl(cloudManager);
     NodeMetric<String> someMetricKey = new NodeMetricImpl<>("solr.jvm:system.properties:user.name");
     String sysprop = "user.name";
-    Set<String> potentialEnvVars = Set.of("PWD", "TMPDIR", "TMP", "TEMP", "USER", "USERNAME", "HOME");
-
-    String envVar = null;
-    for (String env : potentialEnvVars) {
-      if (System.getenv(env) != null) {
-        envVar = env;
-        break;
-      }
-    }
-    if (envVar == null) {
-      fail("None of the potential env vars exist? " + potentialEnvVars);
-    }
     attributeFetcher
         .fetchFrom(cluster.getLiveNodes())
         .requestNodeMetric(NodeMetricImpl.HEAP_USAGE)
@@ -382,11 +370,9 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
         .requestNodeMetric(NodeMetricImpl.AVAILABLE_PROCESSORS)
         .requestNodeMetric(someMetricKey)
         .requestNodeSystemProperty(sysprop)
-        .requestNodeEnvironmentVariable(envVar)
         .requestCollectionMetrics(collection, Set.of(ReplicaMetricImpl.INDEX_SIZE_GB, ReplicaMetricImpl.QUERY_RATE_1MIN, ReplicaMetricImpl.UPDATE_RATE_1MIN));
     AttributeValues attributeValues = attributeFetcher.fetchAttributes();
     String userName = System.getProperty("user.name");
-    String envVarValue = System.getenv(envVar);
     // node metrics
     for (Node node : cluster.getLiveNodes()) {
       Optional<Double> doubleOpt = attributeValues.getNodeMetric(node, NodeMetricImpl.HEAP_USAGE);
@@ -409,9 +395,6 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
       Optional<String> syspropOpt = attributeValues.getSystemProperty(node, sysprop);
       assertTrue("sysprop", syspropOpt.isPresent());
       assertEquals("user.name sysprop", userName, syspropOpt.get());
-      Optional<String> envVarOpt = attributeValues.getEnvironmentVariable(node, envVar);
-      assertTrue("envVar", envVarOpt.isPresent());
-      assertEquals("envVar " + envVar, envVarValue, envVarOpt.get());
     }
     assertTrue(attributeValues.getCollectionMetrics(COLLECTION).isPresent());
     CollectionMetrics collectionMetrics = attributeValues.getCollectionMetrics(COLLECTION).get();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java
index ccc6583..a6ae53e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java
@@ -209,9 +209,6 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter
         if (tag.startsWith(SYSPROP)) {
           metricsKeyVsTag.computeIfAbsent("solr.jvm:system.properties:" + tag.substring(SYSPROP.length()), k -> new HashSet<>())
               .add(tag);
-        } else if (tag.startsWith(SYSENV)) {
-            metricsKeyVsTag.computeIfAbsent("solr.jvm:system.env:" + tag.substring(SYSENV.length()), k -> new HashSet<>())
-              .add(tag);
         } else if (tag.startsWith(METRICS_PREFIX)) {
           metricsKeyVsTag.computeIfAbsent(tag.substring(METRICS_PREFIX.length()), k -> new HashSet<>())
               .add(tag);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/rule/ImplicitSnitch.java b/solr/solrj/src/java/org/apache/solr/common/cloud/rule/ImplicitSnitch.java
index acc412f..afada51 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/rule/ImplicitSnitch.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/rule/ImplicitSnitch.java
@@ -49,7 +49,6 @@ public class ImplicitSnitch extends Snitch {
   public static final String ROLE = "role";
   public static final String NODEROLE = "nodeRole";
   public static final String SYSPROP = "sysprop.";
-  public static final String SYSENV = "sysenv.";
   public static final String SYSLOADAVG = "sysLoadAvg";
   public static final String HEAPUSAGE = "heapUsage";
   public static final List<String> IP_SNITCHES = Collections.unmodifiableList(Arrays.asList("ip_1", "ip_2", "ip_3", "ip_4"));