Merge "Extend buffer for the telegraf openstack output plugin"
diff --git a/_modules/keystonev3/common.py b/_modules/keystonev3/common.py
index 9a7744b..6fdbf18 100644
--- a/_modules/keystonev3/common.py
+++ b/_modules/keystonev3/common.py
@@ -111,12 +111,14 @@
                     kwargs.pop(k)
             url, json  = func(*args, **kwargs)
             response = None
+            last_exception = None
             for i in range(connect_retries):
                 try:
                   response = getattr(adapter, method)(
                       url, connect_retries=connect_retries,
                       json=json)
                 except Exception as e:
+                    last_exception = e
                     if not hasattr(e, 'http_status') or (e.http_status >= 500
                         or e.http_status == 0):
                         msg = ("Got retriable exception when contacting "
@@ -125,7 +127,13 @@
                         log.error(msg % (connect_retry_delay, i, connect_retries))
                         time.sleep(connect_retry_delay)
                         continue
-                break
+                    else:
+                        break
+                else:
+                   last_exception = None
+                   break
+            if last_exception:
+                raise KeystoneException(last_exception.message)
             if not response or not response.content:
                 return {}
             try:
diff --git a/_states/keystonev3.py b/_states/keystonev3.py
index 6962290..d390c14 100644
--- a/_states/keystonev3.py
+++ b/_states/keystonev3.py
@@ -14,13 +14,16 @@
 
 def endpoint_present(name, url, interface, service_id, cloud_name, **kwargs):
 
+    ekwargs = {}
+    if 'region_id' in kwargs:
+      ekwargs['region_id'] = kwargs['region_id']
     service_id = _keystonev3_call(
         'service_get_details', service_id,
         cloud_name=cloud_name)['service']['id']
 
     endpoints = _keystonev3_call(
         'endpoint_list', name=name, service_id=service_id, interface=interface,
-        cloud_name=cloud_name)['endpoints']
+        cloud_name=cloud_name, **ekwargs)['endpoints']
 
     if not endpoints:
         try:
@@ -248,7 +251,7 @@
                 'user_create', name=name, cloud_name=cloud_name, **kwargs
             )
         except Exception as e:
-            log.error('Keystone user create failed with {}'.format(e))
+            log.error('Keystone user create failed with: {}'.format(e))
             return _create_failed(name, 'user')
         return _created(name, 'user', resp)
 
diff --git a/keystone/client/resources/v3.sls b/keystone/client/resources/v3.sls
index 8f58f0c..8cac028 100644
--- a/keystone/client/resources/v3.sls
+++ b/keystone/client/resources/v3.sls
@@ -214,6 +214,8 @@
       {%- if role.role_domain_id is defined %}
     - role_domain_id: {{ role.role_domain_id }}
       {%- endif %}
+    - require:
+      - keystone_user_{{ user_name }}
 
     {%- elif role.get('status', 'assigned') == 'unassigned' %}