[knox] branch master updated: KNOX-2357 - Descriptor handler should not default discovery type to Ambari unless there is discovery configuration (#326)

2020-04-27 Thread pzampino
This is an automated email from the ASF dual-hosted git repository.

pzampino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
 new dbdfe7f  KNOX-2357 - Descriptor handler should not default discovery 
type to Ambari unless there is discovery configuration (#326)
dbdfe7f is described below

commit dbdfe7fc23c3e2f05deb0867913cea74c0b0032c
Author: Phil Zampino 
AuthorDate: Mon Apr 27 14:42:35 2020 -0400

KNOX-2357 - Descriptor handler should not default discovery type to Ambari 
unless there is discovery configuration (#326)
---
 .../simple/SimpleDescriptorHandlerTest.java| 64 ++
 .../topology/simple/SimpleDescriptorHandler.java   | 43 ---
 .../topology/simple/SimpleDescriptorMessages.java  | 10 +++-
 3 files changed, 108 insertions(+), 9 deletions(-)

diff --git 
a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
 
b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
index d6ecc81..58304a2 100644
--- 
a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
+++ 
b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
@@ -129,6 +129,70 @@ public class SimpleDescriptorHandlerTest {
 "\n" +
 "\n";
 
+
+@Test
+public void testSkipDiscovery_NoDiscoveryConfig() throws Exception {
+// There should be no exception because in this case, discovery should 
be skipped altogether
+doTestDiscoveryConfig(null, null, null, null, null);
+}
+
+private void doTestDiscoveryConfig(final String discoveryType,
+   final String address,
+   final String clusterName,
+   final String user,
+   final String pwdAlias) throws Exception 
{
+GatewayConfig gc = EasyMock.createNiceMock(GatewayConfig.class);
+EasyMock.replay(gc);
+
+// Write the externalized provider config to a temp file
+File providerConfig = new File(System.getProperty("java.io.tmpdir"), 
"test-providers.xml");
+FileUtils.write(providerConfig, TEST_PROVIDER_CONFIG, 
StandardCharsets.UTF_8);
+
+// Mock out the simple descriptor
+SimpleDescriptor testDescriptor = 
EasyMock.createNiceMock(SimpleDescriptor.class);
+
EasyMock.expect(testDescriptor.getName()).andReturn("mysimpledescriptor").anyTimes();
+
EasyMock.expect(testDescriptor.getProviderConfig()).andReturn(providerConfig.getAbsolutePath()).anyTimes();
+
EasyMock.expect(testDescriptor.getDiscoveryAddress()).andReturn(address).anyTimes();
+
EasyMock.expect(testDescriptor.getDiscoveryType()).andReturn(discoveryType).anyTimes();
+
EasyMock.expect(testDescriptor.getDiscoveryUser()).andReturn(user).anyTimes();
+
EasyMock.expect(testDescriptor.getDiscoveryPasswordAlias()).andReturn(pwdAlias).anyTimes();
+
EasyMock.expect(testDescriptor.getCluster()).andReturn(clusterName).anyTimes();
+List serviceMocks;
+SimpleDescriptor.Service svc = 
EasyMock.createNiceMock(SimpleDescriptor.Service.class);
+EasyMock.expect(svc.getName()).andReturn("KNOXTOKEN").anyTimes();
+EasyMock.expect(svc.getVersion()).andReturn(null).anyTimes();
+
EasyMock.expect(svc.getURLs()).andReturn(Collections.emptyList()).anyTimes();
+
+Map serviceParams = new HashMap<>();
+serviceParams.put("knox.token.ttl", "12");
+EasyMock.expect(svc.getParams()).andReturn(serviceParams).anyTimes();
+
+EasyMock.replay(svc);
+serviceMocks = Collections.singletonList(svc);
+
+
EasyMock.expect(testDescriptor.getServices()).andReturn(serviceMocks).anyTimes();
+EasyMock.replay(testDescriptor);
+
+File destDir = new 
File(System.getProperty("java.io.tmpdir")).getCanonicalFile();
+File topologyFile = null;
+
+try {
+// Invoke the simple descriptor handler
+Map files =
+SimpleDescriptorHandler.handle(gc,
+testDescriptor,
+providerConfig.getParentFile(), // simple desc 
co-located with provider config
+destDir);
+topologyFile = files.get("topology");
+assertTrue(topologyFile.exists());
+} finally {
+providerConfig.delete();
+if (topologyFile != null) {
+topologyFile.delete();
+}
+}
+}
+
 /*
  * KNOX-1006
  *
diff --git 
a/gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
 
b/gateway-topology-simple/sr

[knox] branch master updated: KNOX-2359 - Knox src zip should not include node_modules folder (#328)

2020-04-27 Thread krisden
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
 new da1e739  KNOX-2359 - Knox src zip should not include node_modules 
folder (#328)
da1e739 is described below

commit da1e739a93d31cdd71d358df79e4a388cc4a24ab
Author: Kevin Risden 
AuthorDate: Mon Apr 27 14:25:48 2020 -0400

KNOX-2359 - Knox src zip should not include node_modules folder (#328)

Signed-off-by: Kevin Risden 
---
 src/assembly.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/assembly.xml b/src/assembly.xml
index 58ffa86..60565fa 100644
--- a/src/assembly.xml
+++ b/src/assembly.xml
@@ -32,7 +32,8 @@
 **/.settings/**
 **/.idea/**
 **/*.iml
+**/node_modules/**
 
 
 
-
\ No newline at end of file
+



[knox] branch master updated: KNOX-2354 An HBASEJARS service which can proxy HBase jars hosted by t… (#325)

2020-04-27 Thread krisden
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
 new bbcaaff  KNOX-2354 An HBASEJARS service which can proxy HBase jars 
hosted by t… (#325)
bbcaaff is described below

commit bbcaaff1d3483d706f7d76c344920b4f755809b7
Author: Josh Elser 
AuthorDate: Mon Apr 27 13:32:26 2020 -0400

KNOX-2354 An HBASEJARS service which can proxy HBase jars hosted by t… 
(#325)

* KNOX-2354 An HBASEJARS service which can proxy HBase jars hosted by the 
HBASEUI

In HBase, we can host a "mini" maven repo in hbase itself which a maven
application can point to.

We want this to be in its own service because it has different semantics
than the normal hbaseUI service has (e.g. one would be hooked up to SSO
login, but SSO won't work against that), and Maven cannot function with
the query-string based backend-routing that we do to make the HBaseUI
look like a normal website (instead of a collection of independent
webservers).

* Add some context as to why this custom dispatch is here.
---
 .../resources/services/hbasejars/2.2.0/rewrite.xml | 49 ++
 .../resources/services/hbasejars/2.2.0/service.xml | 48 +
 2 files changed, 97 insertions(+)

diff --git 
a/gateway-service-definitions/src/main/resources/services/hbasejars/2.2.0/rewrite.xml
 
b/gateway-service-definitions/src/main/resources/services/hbasejars/2.2.0/rewrite.xml
new file mode 100644
index 000..d291305
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/hbasejars/2.2.0/rewrite.xml
@@ -0,0 +1,49 @@
+
+
+  
+  
+
+  
+  
+
+  
+
+  
+  
+
+  
+  
+  
+
+  
+
+  
+  
+
+
+  
+  
+  
+
+  
+  
+
+  
+
diff --git 
a/gateway-service-definitions/src/main/resources/services/hbasejars/2.2.0/service.xml
 
b/gateway-service-definitions/src/main/resources/services/hbasejars/2.2.0/service.xml
new file mode 100644
index 000..4a75572
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/hbasejars/2.2.0/service.xml
@@ -0,0 +1,48 @@
+
+
+
+API
+/hbase/maven
+Jar hosting for HBase
+Static hosting of HBase client jars from the backend 
HBase UI.
+
+
+
+
+
+
+
+
+
+   
+   
+
+
+  
+  
+  
+  
+
+
+
+
+



[knox] branch master updated: KNOX-2351 - Catching any errors while monitoring CM configuration changes (#324)

2020-04-27 Thread smolnar
This is an automated email from the ASF dual-hosted git repository.

smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
 new f96b62d  KNOX-2351 - Catching any errors while monitoring CM 
configuration changes (#324)
f96b62d is described below

commit f96b62d133d300519fc45f295f5e7a2b58922949
Author: Sandor Molnar 
AuthorDate: Mon Apr 27 16:58:09 2020 +0200

KNOX-2351 - Catching any errors while monitoring CM configuration changes 
(#324)
---
 .../ClouderaManagerServiceDiscoveryMessages.java   |   3 +
 .../cm/monitor/PollingConfigurationAnalyzer.java   | 153 +++--
 2 files changed, 82 insertions(+), 74 deletions(-)

diff --git 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java
 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java
index 289c752..7f7c644 100644
--- 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java
+++ 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryMessages.java
@@ -126,6 +126,9 @@ public interface ClouderaManagerServiceDiscoveryMessages {
   @Message(level = MessageLevel.DEBUG, text = "Checking {0} @ {1} for 
configuration changes...")
   void checkingClusterConfiguration(String clusterName, String 
discoveryAddress);
 
+  @Message(level = MessageLevel.ERROR, text = "Error while monitoring 
ClouderaManager configuration changes: {0}")
+  void clouderaManagerConfigurationChangesMonitoringError(@StackTrace(level = 
MessageLevel.DEBUG) Exception e);
+
   @Message(level = MessageLevel.ERROR,
   text = "Error getting service configuration details from 
ClouderaManager: {0}")
   void clouderaManagerConfigurationAPIError(@StackTrace(level = 
MessageLevel.DEBUG) ApiException e);
diff --git 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
index fb8d73c..4b7935f 100644
--- 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
+++ 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
@@ -162,93 +162,98 @@ public class PollingConfigurationAnalyzer implements 
Runnable {
 isActive = true;
 
 while (isActive) {
-  List clustersToStopMonitoring = new ArrayList<>();
+  try {
+final List clustersToStopMonitoring = new ArrayList<>();
+
+for (Map.Entry> entry : 
configCache.getClusterNames().entrySet()) {
+  String address = entry.getKey();
+  for (String clusterName : entry.getValue()) {
+log.checkingClusterConfiguration(clusterName, address);
+
+// Check here for existing descriptor references, and add to the 
removal list if there are not any
+if (!clusterReferencesExist(address, clusterName)) {
+  clustersToStopMonitoring.add(address + FQCN_DELIM + clusterName);
+  continue;
+}
 
-  for (Map.Entry> entry : 
configCache.getClusterNames().entrySet()) {
-String address = entry.getKey();
-for (String clusterName : entry.getValue()) {
-  log.checkingClusterConfiguration(clusterName, address);
+// Configuration changes don't mean anything without corresponding 
service start/restarts. Therefore, monitor
+// start events, and check the configuration only of the restarted 
service(s) to identify changes
+// that should trigger re-discovery.
+final List relevantEvents = getRelevantEvents(address, 
clusterName);
 
-  // Check here for existing descriptor references, and add to the 
removal list if there are not any
-  if (!clusterReferencesExist(address, clusterName)) {
-clustersToStopMonitoring.add(address + FQCN_DELIM + clusterName);
-continue;
+// If there are no recent start events, then nothing to do now
+if (!relevantEvents.isEmpty()) {
+  // If a change has occurred, notify the listeners
+  if (hasConfigChanged(address, clusterName, relevantEvents)) {
+notifyChangeListener(address, clusterName);
+  }
+}
   }
+}
 
-  // Configuration changes don't mean anything without corresponding 
service start/restarts. Therefore, monitor
-  // start events, and check the configuration only of the restarted 
service(s) to identify changes
-  // that should trigger re-discovery.
-