diff --git a/awx/main/conf.py b/awx/main/conf.py
index bbdf159ae6..098b84f639 100644
--- a/awx/main/conf.py
+++ b/awx/main/conf.py
@@ -322,5 +322,5 @@ register(
help_text=_('Useful to uniquely identify Tower instances.'),
category=_('Logging'),
category_slug='logging',
- default=None,
+ default='',
)
diff --git a/awx/main/consumers.py b/awx/main/consumers.py
index c42f16ef21..ff55507939 100644
--- a/awx/main/consumers.py
+++ b/awx/main/consumers.py
@@ -2,10 +2,11 @@ import json
import logging
import urllib
-from channels import Group
+from channels import Group, channel_layers
from channels.sessions import channel_session
from channels.handler import AsgiRequest
+from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from django.contrib.auth.models import User
@@ -49,11 +50,19 @@ def ws_disconnect(message):
@channel_session
def ws_receive(message):
from awx.main.access import consumer_access
+ channel_layer_settings = channel_layers.configs[message.channel_layer.alias]
+ max_retries = channel_layer_settings.get('RECEIVE_MAX_RETRY', settings.CHANNEL_LAYER_RECEIVE_MAX_RETRY)
user_id = message.channel_session.get('user_id', None)
if user_id is None:
- logger.error("No valid user found for websocket.")
+ retries = message.content.get('connect_retries', 0) + 1
+ message.content['connect_retries'] = retries
message.reply_channel.send({"text": json.dumps({"error": "no valid user"})})
+ retries_left = max_retries - retries
+ if retries_left > 0:
+ message.channel_layer.send(message.channel.name, message.content)
+ else:
+ logger.error("No valid user found for websocket.")
return None
user = User.objects.get(pk=user_id)
diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py
index f17b2b4c55..2ccae7fdaf 100644
--- a/awx/main/models/unified_jobs.py
+++ b/awx/main/models/unified_jobs.py
@@ -880,7 +880,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
workflow_node_id=self.workflow_node_id))
return websocket_data
- def websocket_emit_status(self, status):
+ def _websocket_emit_status(self, status):
status_data = dict(unified_job_id=self.id, status=status)
status_data.update(self.websocket_emit_data())
status_data['group_name'] = 'jobs'
@@ -890,6 +890,9 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
status_data['group_name'] = "workflow_events"
emit_channel_notification('workflow_events-' + str(self.workflow_job_id), status_data)
+ def websocket_emit_status(self, status):
+ connection.on_commit(lambda: self._websocket_emit_status(status))
+
def notification_data(self):
return dict(id=self.id,
name=self.name,
diff --git a/awx/main/scheduler/__init__.py b/awx/main/scheduler/__init__.py
index a48ca3ad23..dc0a4c82e0 100644
--- a/awx/main/scheduler/__init__.py
+++ b/awx/main/scheduler/__init__.py
@@ -382,7 +382,7 @@ class TaskManager():
))
task_obj.save()
_send_notification_templates(task_obj, 'failed')
- connection.on_commit(lambda: task_obj.websocket_emit_status('failed'))
+ task_obj.websocket_emit_status('failed')
logger.error("Task %s appears orphaned... marking as failed" % task)
diff --git a/awx/main/tasks.py b/awx/main/tasks.py
index 584e6ce0bb..91ef460f16 100644
--- a/awx/main/tasks.py
+++ b/awx/main/tasks.py
@@ -218,7 +218,11 @@ def _send_notification_templates(instance, status_str):
raise ValueError(_("status_str must be either succeeded or failed"))
notification_templates = instance.get_notification_templates()
if notification_templates:
- all_notification_templates = set(notification_templates.get('success', []) + notification_templates.get('any', []))
+ if status_str == 'succeeded':
+ notification_template_type = 'success'
+ else:
+ notification_template_type = 'error'
+ all_notification_templates = set(notification_templates.get(notification_template_type, []) + notification_templates.get('any', []))
if len(all_notification_templates):
try:
(notification_subject, notification_body) = getattr(instance, 'build_notification_%s_message' % status_str)()
diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py
index 090e939914..0901961fa5 100644
--- a/awx/settings/defaults.py
+++ b/awx/settings/defaults.py
@@ -866,6 +866,11 @@ TOWER_SETTINGS_MANIFEST = {}
LOG_AGGREGATOR_ENABLED = False
+# The number of retry attempts for websocket session establishment
+# If you're encountering issues establishing websockets in clustered Tower,
+# raising this value can help
+CHANNEL_LAYER_RECEIVE_MAX_RETRY = 10
+
# Logging configuration.
LOGGING = {
'version': 1,
diff --git a/awx/sso/views.py b/awx/sso/views.py
index 2a68deec1a..80092a8040 100644
--- a/awx/sso/views.py
+++ b/awx/sso/views.py
@@ -50,6 +50,7 @@ class CompleteView(BaseRedirectView):
try:
token = AuthToken.objects.filter(user=request.user,
request_hash=request_hash,
+ reason='',
expires__gt=now())[0]
token.refresh()
logger.info(smart_text(u"User {} logged in".format(self.request.user.username)))
diff --git a/awx/ui/client/src/forms/Projects.js b/awx/ui/client/src/forms/Projects.js
index 2185381e69..d5f165bce8 100644
--- a/awx/ui/client/src/forms/Projects.js
+++ b/awx/ui/client/src/forms/Projects.js
@@ -137,6 +137,7 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
},
ngShow: "scm_type && scm_type.value !== 'manual'",
sourceModel: 'credential',
+ awLookupType: 'scm_credential',
sourceField: 'name',
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
subForm: 'sourceSubForm'
diff --git a/awx/ui/client/src/job-results/host-event/host-event-modal.partial.html b/awx/ui/client/src/job-results/host-event/host-event-modal.partial.html
index f8d488b4b3..916add240d 100644
--- a/awx/ui/client/src/job-results/host-event/host-event-modal.partial.html
+++ b/awx/ui/client/src/job-results/host-event/host-event-modal.partial.html
@@ -33,7 +33,7 @@
MODULE
- {{module_name}}
+ {{module_name}}
diff --git a/awx/ui/client/src/job-results/host-event/host-event.block.less b/awx/ui/client/src/job-results/host-event/host-event.block.less
index e5797643b3..84fb77c1f6 100644
--- a/awx/ui/client/src/job-results/host-event/host-event.block.less
+++ b/awx/ui/client/src/job-results/host-event/host-event.block.less
@@ -126,6 +126,9 @@
max-width: 13em;
flex: 0 1 13em;
}
+.HostEvent-field--monospaceContent{
+ font-family: monospace;
+}
.HostEvent-details--left, .HostEvent-details--right{
flex: 1 1 47%;
}
@@ -175,7 +178,7 @@
border-right: 1px solid #ccc;
border-bottom-left-radius: 5px;
color: #999;
- font-family: monospace;
+ font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
position: fixed;
padding: 4px 3px 0 5px;
text-align: right;
diff --git a/awx/ui/client/src/job-results/host-event/host-event.controller.js b/awx/ui/client/src/job-results/host-event/host-event.controller.js
index 781f971793..fe8a65b268 100644
--- a/awx/ui/client/src/job-results/host-event/host-event.controller.js
+++ b/awx/ui/client/src/job-results/host-event/host-event.controller.js
@@ -36,9 +36,9 @@
// grab standard out & standard error if present from the host
// event's "res" object, for things like Ansible modules
try{
- $scope.module_name = hostEvent.event_data.res.invocation.module_name || hostEvent.event_data.task_action || "No result found";
- $scope.stdout = hostEvent.event_data.res.stdout;
- $scope.stderr = hostEvent.event_data.res.stderr;
+ $scope.module_name = hostEvent.event_data.task_action || "No result found";
+ $scope.stdout = hostEvent.event_data.res.stdout ? hostEvent.event_data.res.stdout : hostEvent.event_data.res.stdout === "" ? " " : undefined;
+ $scope.stderr = hostEvent.event_data.res.stderr ? hostEvent.event_data.res.stderr : hostEvent.event_data.res.stderr === "" ? " " : undefined;
$scope.json = hostEvent.event_data.res;
}
catch(err){
diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js
index 9c09f2f4ed..311a316f0c 100644
--- a/awx/ui/client/src/shared/directives.js
+++ b/awx/ui/client/src/shared/directives.js
@@ -482,6 +482,7 @@ function(ConfigurationUtils, i18n, $rootScope) {
autopopulateLookup,
modelKey = attrs.ngModel,
modelName = attrs.source,
+ lookupType = attrs.awlookuptype,
watcher = attrs.awRequiredWhen || undefined,
watchBasePath;
@@ -516,10 +517,14 @@ function(ConfigurationUtils, i18n, $rootScope) {
}
else {
basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath');
- switch(modelName) {
+ let switchType = lookupType ? lookupType : modelName;
+ switch(switchType) {
case 'credential':
query = '?kind=ssh&role_level=use_role';
break;
+ case 'scm_credential':
+ query = '?kind=scm&role_level=use_role';
+ break;
case 'network_credential':
query = '?kind=net&role_level=use_role';
break;
@@ -601,7 +606,7 @@ function(ConfigurationUtils, i18n, $rootScope) {
query = elm.attr('data-query');
query = query.replace(/\:value/, encodeURIComponent(viewValue));
- let base = ctrl.$name.split('_name')[0];
+ let base = lookupType ? lookupType : ctrl.$name.split('_name')[0];
if (attrs.watchbasepath !== undefined && scope[attrs.watchbasepath] !== undefined) {
basePath = scope[attrs.watchbasepath];
query += '&role_level=use_role';
@@ -612,6 +617,9 @@ function(ConfigurationUtils, i18n, $rootScope) {
case 'credential':
query += '&kind=ssh&role_level=use_role';
break;
+ case 'scm_credential':
+ query += '&kind=scm&role_level=use_role';
+ break;
case 'network_credential':
query += '&kind=net&role_level=use_role';
break;
diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js
index 600675f341..a1a2a6761f 100644
--- a/awx/ui/client/src/shared/form-generator.js
+++ b/awx/ui/client/src/shared/form-generator.js
@@ -1384,6 +1384,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += `data-basePath="${field.basePath}"`;
html += `data-source="${field.sourceModel}"`;
html += `data-query="?${field.sourceField}__iexact=:value"`;
+ html += (field.awLookupType !== undefined) ? ` data-awLookupType=${field.awLookupType} ` : "";
html += (field.autopopulateLookup !== undefined) ? ` autopopulateLookup=${field.autopopulateLookup} ` : "";
html += (field.watchBasePath !== undefined) ? ` watchBasePath=${field.watchBasePath} ` : "";
html += `ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 300, 'blur': 0 } }"`;
diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js
index d3b1d216f1..b7d3a45f6b 100644
--- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js
+++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js
@@ -110,7 +110,7 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', '
function setDefaults(term) {
if ($scope.list.defaultSearchParams) {
- return $scope.list.defaultSearchParams(term);
+ return $scope.list.defaultSearchParams(encodeURIComponent(term));
} else {
return {
search: encodeURIComponent(term)
diff --git a/docs/licenses/asgi-amqp.txt b/docs/licenses/asgi-amqp.txt
new file mode 100644
index 0000000000..731a737315
--- /dev/null
+++ b/docs/licenses/asgi-amqp.txt
@@ -0,0 +1,9 @@
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/requirements/requirements.in b/requirements/requirements.in
index b0b5164b25..5d3b4c0e45 100644
--- a/requirements/requirements.in
+++ b/requirements/requirements.in
@@ -5,7 +5,7 @@
-e git+https://github.com/chrismeyersfsu/pyrax@tower#egg=pyrax
apache-libcloud==1.3.0
appdirs==1.4.2
-asgi-amqp==0.4.0
+asgi-amqp==0.4.1
azure==2.0.0rc6
backports.ssl-match-hostname==3.5.0.1
boto==2.45.0
diff --git a/requirements/requirements.txt b/requirements/requirements.txt
index 2489dc5b36..0012ad8330 100644
--- a/requirements/requirements.txt
+++ b/requirements/requirements.txt
@@ -14,7 +14,7 @@ amqp==1.4.9 # via kombu
anyjson==0.3.3 # via kombu
apache-libcloud==1.3.0
appdirs==1.4.2
-asgi-amqp==0.4.0
+asgi-amqp==0.4.1
asgiref==1.0.0 # via asgi-amqp, channels, daphne
attrs==16.3.0 # via service-identity
autobahn==0.17.0 # via daphne