You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/03/11 10:55:32 UTC

[camel] branch master updated: CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, EKS

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 460a565  CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, EKS
460a565 is described below

commit 460a56519fbea06d3400a4885c1c6abd0a2a86ea
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 11 11:55:08 2020 +0100

    CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, EKS
---
 .../camel/component/aws2/eks/EKS2Component.java    | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java
index 885478b..af5e97d 100644
--- a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java
+++ b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Component.java
@@ -24,6 +24,9 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.services.eks.EksClient;
 
 /**
@@ -32,6 +35,8 @@ import software.amazon.awssdk.services.eks.EksClient;
 @Component("aws2-eks")
 public class EKS2Component extends DefaultComponent {
 
+    private static final Logger LOG = LoggerFactory.getLogger(EKS2Component.class);
+
     @Metadata
     private EKS2Configuration configuration = new EKS2Configuration();
 
@@ -50,7 +55,7 @@ public class EKS2Component extends DefaultComponent {
         EKS2Configuration configuration = this.configuration != null ? this.configuration.copy() : new EKS2Configuration();
         EKS2Endpoint endpoint = new EKS2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        checkAndSetRegistryClient(configuration);
+        checkAndSetRegistryClient(configuration, endpoint);
         if (configuration.getEksClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("Amazon eks client or accessKey and secretKey must be specified");
         }
@@ -69,10 +74,18 @@ public class EKS2Component extends DefaultComponent {
         this.configuration = configuration;
     }
 
-    private void checkAndSetRegistryClient(EKS2Configuration configuration) {
-        Set<EksClient> clients = getCamelContext().getRegistry().findByType(EksClient.class);
-        if (clients.size() == 1) {
-            configuration.setEksClient(clients.stream().findFirst().get());
+    private void checkAndSetRegistryClient(EKS2Configuration configuration, EKS2Endpoint endpoint) {
+        if (ObjectHelper.isEmpty(endpoint.getConfiguration().getEksClient())) {
+            LOG.debug("Looking for an EksClient instance in the registry");
+            Set<EksClient> clients = getCamelContext().getRegistry().findByType(EksClient.class);
+            if (clients.size() == 1) {
+                LOG.debug("Found exactly one EksClient instance in the registry");
+                configuration.setEksClient(clients.stream().findFirst().get());
+            } else {
+                LOG.debug("No EksClient instance in the registry");
+            }
+        } else {
+            LOG.debug("EksClient instance is already set at endpoint level: skipping the check in the registry");
         }
     }
 }