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

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit c7af4b27026f863b1c807473e926301eeff0f91d
Author: frogfather <[email protected]>
AuthorDate: Thu Dec 19 15:17:32 2019 +0000

    add check for missing endpoint
---
 .../brooklyn/location/jclouds/AbstractComputeServiceRegistry.java  | 7 ++++++-
 .../java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/AbstractComputeServiceRegistry.java
 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/AbstractComputeServiceRegistry.java
index b9274f4..1520df3 100644
--- 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/AbstractComputeServiceRegistry.java
+++ 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/AbstractComputeServiceRegistry.java
@@ -57,7 +57,7 @@ public abstract class AbstractComputeServiceRegistry 
implements ComputeServiceRe
     private final Map<Map<?, ?>, ComputeService> cachedComputeServices = new 
ConcurrentHashMap<>();
 
     @Override
-    public ComputeService findComputeService(ConfigBag conf, boolean 
allowReuse) {
+    public ComputeService findComputeService(ConfigBag conf, boolean 
allowReuse) throws IllegalArgumentException {
         JCloudsPropertiesBuilder propertiesBuilder = new 
JCloudsPropertiesBuilder(conf)
                 .setCommonJcloudsProperties();
 
@@ -82,6 +82,11 @@ public abstract class AbstractComputeServiceRegistry 
implements ComputeServiceRe
 
         Iterable<? extends Module> modules = modulesBuilder.build();
 
+        //Check for missing endpoint when provider is azure
+        if (properties.getProperty(Constants.PROPERTY_ENDPOINT) == null && 
("azurecompute-arm".equals(provider))) {
+            throw new IllegalArgumentException("Endpoint property cannot be 
null when provider is azure-arm");
+        }
+
         Supplier<ComputeService> computeServiceSupplier = new 
ComputeServiceSupplier(conf, modules, properties);
         if (allowReuse) {
             return cachedComputeServices.computeIfAbsent(makeCacheKey(conf, 
properties), key -> computeServiceSupplier.get());
diff --git 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
index 8d9a889..c6940a8 100644
--- 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
+++ 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
@@ -612,6 +612,9 @@ public class JcloudsLocation extends 
AbstractCloudMachineProvisioningLocation im
         for (int i = 1; i <= attempts; i++) {
             try {
                 return obtainOnce(setup);
+            } catch (IllegalArgumentException e) {
+                LOG.warn("Attempt #{}/{} to obtain machine threw error: {}", 
new Object[]{i, attempts, e});
+                exceptions.add(e);
             } catch (RuntimeException e) {
                 LOG.warn("Attempt #{}/{} to obtain machine threw error: {}", 
new Object[]{i, attempts, e});
                 exceptions.add(e);

Reply via email to