From 68d7119337d820fbaff133497ce727d807087127 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 24 Nov 2015 09:51:48 -0500 Subject: [PATCH 01/21] Bump minor version for 2.4.2 release --- awx/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/__init__.py b/awx/__init__.py index 0a56dd220a..d506b6f1c0 100644 --- a/awx/__init__.py +++ b/awx/__init__.py @@ -6,7 +6,7 @@ import sys import warnings import site -__version__ = '2.4.1' +__version__ = '2.4.2' __all__ = ['__version__'] From e69fdfa79b4fd976be891147ece4095fc8c61371 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 24 Nov 2015 11:20:27 -0500 Subject: [PATCH 02/21] Improvements to the package scanner * Support Amazon (because it's RH based) * Switch to using module_utils's get_distribution() method for more efficient distro detection --- awx/plugins/library/scan_packages.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/awx/plugins/library/scan_packages.py b/awx/plugins/library/scan_packages.py index 8077cfe45d..b7398ab202 100755 --- a/awx/plugins/library/scan_packages.py +++ b/awx/plugins/library/scan_packages.py @@ -72,14 +72,18 @@ def main(): module = AnsibleModule( argument_spec = dict()) - packages = [] - # TODO: module_utils/basic.py in ansible contains get_distribution() and get_distribution_version() - # which can be used here and is accessible by this script instead of this basic detector. - if os.path.exists("/etc/redhat-release"): + ans_dist = get_distribution() + if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon'): packages = rpm_package_list() - elif os.path.exists("/etc/os-release"): + elif ans_dist in ('Ubuntu'): packages = deb_package_list() - results = dict(ansible_facts=dict(packages=packages)) + else: + packages = None + + if packages is not None: + results = dict(ansible_facts=dict(packages=packages)) + else: + results = dict(skipped=True, msg="Unsupported Distribution") module.exit_json(**results) main() From 13c80375eab2ca44db51295dbae975cc21f57c46 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 23 Nov 2015 13:40:05 -0500 Subject: [PATCH 03/21] Fix job template job sorting "started" isn't a good field to sort on as it can be Null. "created" will always be available. --- awx/api/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 1ab055d8af..bf258cc524 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1505,7 +1505,7 @@ class JobTemplateSerializer(UnifiedJobTemplateSerializer, JobOptionsSerializer): else: d['can_copy'] = False d['can_edit'] = False - d['recent_jobs'] = [{'id': x.id, 'status': x.status, 'finished': x.finished} for x in obj.jobs.filter(active=True).order_by('-started')[:10]] + d['recent_jobs'] = [{'id': x.id, 'status': x.status, 'finished': x.finished} for x in obj.jobs.filter(active=True).order_by('-created')[:10]] return d def validate_survey_enabled(self, attrs, source): From 772b7d201ec5287d179df1b08c865c8436cc0fc1 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 24 Nov 2015 12:15:37 -0500 Subject: [PATCH 04/21] Add SUSE, OpenSuse and Debian to scan_packages Also strip the output of get_distribution() since the suse variants seem to have extra whitespace in the string output. --- awx/plugins/library/scan_packages.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/awx/plugins/library/scan_packages.py b/awx/plugins/library/scan_packages.py index b7398ab202..e275144cd1 100755 --- a/awx/plugins/library/scan_packages.py +++ b/awx/plugins/library/scan_packages.py @@ -71,11 +71,13 @@ def deb_package_list(): def main(): module = AnsibleModule( argument_spec = dict()) - - ans_dist = get_distribution() - if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon'): + import os + os.system('echo "%s" > /tmp/foo' % get_distribution()) + ans_dist = get_distribution().strip() + if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon', 'Suse linux enterprise server', 'Opensuse'): + os.system('echo "in rpm_package_list for %s" >> /tmp/foo' % ans_dist) packages = rpm_package_list() - elif ans_dist in ('Ubuntu'): + elif ans_dist in ('Ubuntu', 'Debian'): packages = deb_package_list() else: packages = None From d95470066c98ea509d6380ccba69ee68518ad824 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 24 Nov 2015 12:35:39 -0500 Subject: [PATCH 05/21] Remove stray debugging lines --- awx/plugins/library/scan_packages.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/awx/plugins/library/scan_packages.py b/awx/plugins/library/scan_packages.py index e275144cd1..3f9af5472c 100755 --- a/awx/plugins/library/scan_packages.py +++ b/awx/plugins/library/scan_packages.py @@ -71,8 +71,6 @@ def deb_package_list(): def main(): module = AnsibleModule( argument_spec = dict()) - import os - os.system('echo "%s" > /tmp/foo' % get_distribution()) ans_dist = get_distribution().strip() if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon', 'Suse linux enterprise server', 'Opensuse'): os.system('echo "in rpm_package_list for %s" >> /tmp/foo' % ans_dist) From a1fbee4fa01a4dfaadcb7f79d4740cd10473221c Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 24 Nov 2015 14:19:09 -0500 Subject: [PATCH 06/21] Refactor scan_packages for os detection * Use setup facts ansible_os_family for os family detection now. Add support for Suse and it's ilk (which has a pretty ugly OS family implementation --- awx/playbooks/scan_facts.yml | 1 + awx/plugins/library/scan_packages.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/awx/playbooks/scan_facts.yml b/awx/playbooks/scan_facts.yml index 2c51c50709..1b90380c62 100644 --- a/awx/playbooks/scan_facts.yml +++ b/awx/playbooks/scan_facts.yml @@ -4,6 +4,7 @@ scan_use_recursive: false tasks: - scan_packages: + os_family: '{{ ansible_os_family }}' - scan_services: - scan_files: paths: '{{ scan_file_paths }}' diff --git a/awx/plugins/library/scan_packages.py b/awx/plugins/library/scan_packages.py index 3f9af5472c..9c47b0800f 100755 --- a/awx/plugins/library/scan_packages.py +++ b/awx/plugins/library/scan_packages.py @@ -70,12 +70,12 @@ def deb_package_list(): def main(): module = AnsibleModule( - argument_spec = dict()) - ans_dist = get_distribution().strip() - if ans_dist in ('Centos', 'Centos linux', 'Red hat enterprise linux server', 'Amazon', 'Suse linux enterprise server', 'Opensuse'): - os.system('echo "in rpm_package_list for %s" >> /tmp/foo' % ans_dist) + argument_spec = dict(os_family=dict(required=True)) + ) + ans_os = module.params['os_family'] + if ans_os in ('RedHat', 'Suse', 'openSUSE Leap'): packages = rpm_package_list() - elif ans_dist in ('Ubuntu', 'Debian'): + elif ans_os == 'Debian': packages = deb_package_list() else: packages = None From 54be15a694084a5f719c454eeec7da0e14ff910f Mon Sep 17 00:00:00 2001 From: Graham Mainwaring Date: Wed, 25 Nov 2015 09:47:29 -0500 Subject: [PATCH 07/21] Revert change to Makefile, which was causing old .deb versions to be dropped from the repo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8665341cb1..ecc7e69210 100644 --- a/Makefile +++ b/Makefile @@ -651,7 +651,7 @@ reprepro: deb-build/$(DEB_NVRA).deb reprepro/conf $(REPREPRO_BIN) $(REPREPRO_OPTS) clearvanished for COMPONENT in non-free $(VERSION); do \ $(REPREPRO_BIN) $(REPREPRO_OPTS) -C $$COMPONENT remove $(DEB_DIST) $(NAME) ; \ - $(REPREPRO_BIN) $(REPREPRO_OPTS) -C $$COMPONENT --ignore=brokenold includedeb $(DEB_DIST) deb-build/$(DEB_NVRA).deb ; \ + $(REPREPRO_BIN) $(REPREPRO_OPTS) -C $$COMPONENT --keepunreferencedfiles --ignore=brokenold includedeb $(DEB_DIST) deb-build/$(DEB_NVRA).deb ; \ done From 4740b21f66bcc5378af68b8893f21555e7a37601 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 30 Nov 2015 09:24:34 -0500 Subject: [PATCH 08/21] Wrapped the SourceChange call in a function so that it can be called without clearing the credential. This fixes a bug where the credential was not showing up in the initial edit dialog even though the data was sent properly via the API. --- awx/ui/client/src/helpers/Groups.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/helpers/Groups.js b/awx/ui/client/src/helpers/Groups.js index 4d7fb0487c..6c2bd6a6c5 100644 --- a/awx/ui/client/src/helpers/Groups.js +++ b/awx/ui/client/src/helpers/Groups.js @@ -790,6 +790,11 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name ParseTypeChange({ scope: properties_scope, field_id: textareaID, onReady: waitStop }); } + function initSourceChange() { + parent_scope.showSchedulesTab = (mode === 'edit' && sources_scope.source && sources_scope.source.value!=="manual") ? true : false; + SourceChange({ scope: sources_scope, form: SourceForm }); + } + // Set modal dimensions based on viewport width ww = $(document).width(); wh = $('body').height(); @@ -1058,7 +1063,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name } } - sources_scope.sourceChange(); //set defaults that rely on source value + initSourceChange(); if (data.source_regions) { if (data.source === 'ec2' || @@ -1470,8 +1475,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name if (sources_scope.credential_name_api_error) { delete sources_scope.credential_name_api_error; } - parent_scope.showSchedulesTab = (mode === 'edit' && sources_scope.source && sources_scope.source.value!=="manual") ? true : false; - SourceChange({ scope: sources_scope, form: SourceForm }); + initSourceChange(); }; }; From 3b4f39742b001d94fac3bee57b1a9edd4dff25fe Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 30 Nov 2015 10:44:37 -0500 Subject: [PATCH 09/21] The "job" href links in the activity stream don't point to the job details page. This is an update to the jobs href to point to /#/jobs/(job.id). --- awx/ui/client/src/widgets/Stream.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/widgets/Stream.js b/awx/ui/client/src/widgets/Stream.js index 5cbd299edf..f05952463b 100644 --- a/awx/ui/client/src/widgets/Stream.js +++ b/awx/ui/client/src/widgets/Stream.js @@ -170,7 +170,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti url += 'home/' + obj.base + 's/?id=' + obj.id; break; case 'job': - url += 'jobs/?id__int=' + obj.id; + url += 'jobs/' + obj.id + '/'; break; case 'inventory': url += 'inventories/' + obj.id + '/'; From 5d3da1460f71e678bdf882cca7d7fed4592d6a7d Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 30 Nov 2015 11:13:21 -0500 Subject: [PATCH 10/21] Fixing up flake8 --- awx/main/middleware.py | 2 +- awx/plugins/library/scan_packages.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/awx/main/middleware.py b/awx/main/middleware.py index 3377ec8cb6..f73758ad7d 100644 --- a/awx/main/middleware.py +++ b/awx/main/middleware.py @@ -5,7 +5,7 @@ import logging import threading import uuid -from django.contrib.auth.models import User, AnonymousUser +from django.contrib.auth.models import User from django.db.models.signals import post_save from django.db import IntegrityError from django.http import HttpResponseRedirect diff --git a/awx/plugins/library/scan_packages.py b/awx/plugins/library/scan_packages.py index 9c47b0800f..ee091db39f 100755 --- a/awx/plugins/library/scan_packages.py +++ b/awx/plugins/library/scan_packages.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import os from ansible.module_utils.basic import * # noqa DOCUMENTATION = ''' From 71a5beaa1f6d250d67950393238d70ebfb871c49 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 30 Nov 2015 11:30:13 -0500 Subject: [PATCH 11/21] correct spelling of consisting in help text --- awx/ui/client/src/forms/JobTemplates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/forms/JobTemplates.js b/awx/ui/client/src/forms/JobTemplates.js index 6d3a82286d..6bff4c4b86 100644 --- a/awx/ui/client/src/forms/JobTemplates.js +++ b/awx/ui/client/src/forms/JobTemplates.js @@ -205,7 +205,7 @@ export default column: 2, awPopOver: "

Provide a comma separated list of tags.

\n" + "

Tags are useful when you have a large playbook, and you want to run a specific part of a play or task.

" + - "

For example, you might have a task consisiting of a long list of actions. Tag values can be assigned to each action. " + + "

For example, you might have a task consisting of a long list of actions. Tag values can be assigned to each action. " + "Suppose the actions have been assigned tag values of "configuration", "packages" and "install".

" + "

If you just want to run the "configuration" and "packages" actions, you would enter the following here " + "in the Job Tags field:

\n
configuration,packages
\n", From 7793850f9e1264684f7d0334dbb28cbbbbf7957a Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Mon, 30 Nov 2015 15:10:41 -0500 Subject: [PATCH 12/21] track modules on system tracking page by index --- awx/ui/client/src/system-tracking/system-tracking.partial.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/system-tracking/system-tracking.partial.html b/awx/ui/client/src/system-tracking/system-tracking.partial.html index cefe3bd7e1..01460f49a8 100644 --- a/awx/ui/client/src/system-tracking/system-tracking.partial.html +++ b/awx/ui/client/src/system-tracking/system-tracking.partial.html @@ -54,7 +54,7 @@ 'is-active': module.isActive, }" ng-click="setActiveModule(module.name)" - ng-repeat="module in modules | orderBy: 'sortKey'"> + ng-repeat="module in modules | orderBy: 'sortKey' track by $index"> {{module.displayName}} From 863a31b6fb5ce4fdf65afd345eb5543d4db5c243 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 30 Nov 2015 15:21:10 -0500 Subject: [PATCH 13/21] Rolled back job url change --- awx/ui/client/src/widgets/Stream.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/widgets/Stream.js b/awx/ui/client/src/widgets/Stream.js index f05952463b..5cbd299edf 100644 --- a/awx/ui/client/src/widgets/Stream.js +++ b/awx/ui/client/src/widgets/Stream.js @@ -170,7 +170,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti url += 'home/' + obj.base + 's/?id=' + obj.id; break; case 'job': - url += 'jobs/' + obj.id + '/'; + url += 'jobs/?id__int=' + obj.id; break; case 'inventory': url += 'inventories/' + obj.id + '/'; From d7e77064a2f69d33d1b4248be3e6fd519295f154 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 30 Nov 2015 15:22:44 -0500 Subject: [PATCH 14/21] When the panel lists were consolidated down the list name was changed to 'all_jobs.' When a job is clicked from the activity stream it should show the job list filtered down by ID. --- awx/ui/client/src/helpers/Jobs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/helpers/Jobs.js b/awx/ui/client/src/helpers/Jobs.js index dac06e03c6..cd3bb677af 100644 --- a/awx/ui/client/src/helpers/Jobs.js +++ b/awx/ui/client/src/helpers/Jobs.js @@ -428,7 +428,7 @@ export default // }, 300); }); - if (base === 'jobs' && list.name === 'completed_jobs') { + if (base === 'jobs' && list.name === 'all_jobs') { if ($routeParams.id__int) { scope[list.iterator + 'SearchField'] = 'id'; scope[list.iterator + 'SearchValue'] = $routeParams.id__int; From f33e17826f22d79725bf60368126a2cc7b60b7f2 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 1 Dec 2015 14:45:35 -0500 Subject: [PATCH 15/21] Disable elasticache instance gathering for aws --- awx/main/tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 93303f511c..eef1590d1a 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1101,6 +1101,7 @@ class RunInventoryUpdate(BaseTask): ec2_opts.setdefault('all_rds_instances', 'False') ec2_opts.setdefault('rds', 'False') ec2_opts.setdefault('nested_groups', 'True') + ec2_opts.setdefault('elasticache', 'False') if inventory_update.instance_filters: ec2_opts.setdefault('instance_filters', inventory_update.instance_filters) group_by = [x.strip().lower() for x in inventory_update.group_by.split(',') if x.strip()] From e79db58b6d9fcf90dccf9514f69ef35b96634339 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 1 Dec 2015 16:02:10 -0500 Subject: [PATCH 16/21] Allow an org admin to delete project updates Only in their purview (where they can delete or change the original project) Plus a bonus unit test! --- awx/main/access.py | 3 +++ awx/main/tests/projects.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/awx/main/access.py b/awx/main/access.py index 4af42b28f2..18ae3a91b1 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -750,6 +750,9 @@ class ProjectUpdateAccess(BaseAccess): def can_cancel(self, obj): return self.can_change(obj, {}) and obj.can_cancel + def can_delete(self, obj): + return obj and self.user.can_access(Project, 'delete', obj.project) + class PermissionAccess(BaseAccess): ''' I can see a permission when: diff --git a/awx/main/tests/projects.py b/awx/main/tests/projects.py index f698267a0c..d12fd89e7b 100644 --- a/awx/main/tests/projects.py +++ b/awx/main/tests/projects.py @@ -1321,6 +1321,28 @@ class ProjectUpdatesTest(BaseTransactionTest): with self.current_user(self.super_django_user): self.post(projects_url, project_data, expect=201) + def test_delete_project_update_as_org_admin(self): + scm_url = getattr(settings, 'TEST_GIT_PUBLIC_HTTPS', + 'https://github.com/ansible/ansible.github.com.git') + if not all([scm_url]): + self.skipTest('no public git repo defined for https!') + projects_url = reverse('api:project_list') + project_data = { + 'name': 'my public git project over https', + 'scm_type': 'git', + 'scm_url': scm_url, + } + org = self.make_organizations(self.super_django_user, 1)[0] + org.admins.add(self.normal_django_user) + with self.current_user(self.super_django_user): + del_proj = self.post(projects_url, project_data, expect=201) + del_proj = Project.objects.get(pk=del_proj["id"]) + org.projects.add(del_proj) + pu = self.check_project_update(del_proj) + pu_url = reverse('api:project_update_detail', args=(pu.id,)) + self.delete(pu_url, expect=403, auth=self.get_other_credentials()) + self.delete(pu_url, expect=204, auth=self.get_normal_credentials()) + def test_public_git_project_over_https(self): scm_url = getattr(settings, 'TEST_GIT_PUBLIC_HTTPS', 'https://github.com/ansible/ansible.github.com.git') From 1fa3d58049be3234f14f3e0b8cd3d8f1ab60b37c Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 2 Dec 2015 13:46:52 -0500 Subject: [PATCH 17/21] fixed custom login info bug --- awx/ui/client/src/login/loginModal/loginModal.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/login/loginModal/loginModal.controller.js b/awx/ui/client/src/login/loginModal/loginModal.controller.js index a2aefb3fdb..d27002d16c 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.controller.js +++ b/awx/ui/client/src/login/loginModal/loginModal.controller.js @@ -115,7 +115,7 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l scope.customLogo = ($AnsibleConfig.custom_logo) ? "custom_console_logo.png" : "tower_console_logo.png"; scope.customLoginInfo = $AnsibleConfig.custom_login_info; - scope.customLoginInfoPresent = ($AnsibleConfig.customLoginInfo) ? true : false; + scope.customLoginInfoPresent = (scope.customLoginInfo) ? true : false; }); // Reset the login form From 780b27e0edc6b6f635ea869bec8dea601a251d37 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 2 Dec 2015 15:40:56 -0500 Subject: [PATCH 18/21] Don't hard-fail if default isn't defined on survey --- awx/main/models/jobs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index dddd91dfc8..ebc6a0fa78 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -293,7 +293,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions): # Overwrite with job template extra vars with survey default vars if self.survey_enabled and 'spec' in self.survey_spec: for survey_element in self.survey_spec.get("spec", []): - if survey_element['default']: + if 'default' in survey_element and survey_element['default']: extra_vars[survey_element['variable']] = survey_element['default'] # transform to dict From a22955d466635440a4b34a27dd2f62da2e460066 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Thu, 3 Dec 2015 09:31:40 -0500 Subject: [PATCH 19/21] Adding a body to our OPTIONS requests fixes 415 error responses in IE11 and Edge. --- awx/ui/client/src/rest/restServices.factory.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/ui/client/src/rest/restServices.factory.js b/awx/ui/client/src/rest/restServices.factory.js index 0d03c7ef9e..32473c2a1b 100644 --- a/awx/ui/client/src/rest/restServices.factory.js +++ b/awx/ui/client/src/rest/restServices.factory.js @@ -258,7 +258,8 @@ export default return $http({ method: 'OPTIONS', url: this.url, - headers: this.headers + headers: this.headers, + data: '' }); } else { return this.createResponse({ From 78ac2ccb553c83172f1cfbcfcb6cbfdc0198a1ea Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Fri, 4 Dec 2015 13:23:43 -0500 Subject: [PATCH 20/21] more robust check added to mongo db connection Calling mongoengine (or pymongo) connect() after already calling connect() resulting in getting the first connection (connection pooling). This is bad if we are relying on connect() to determine if mongo is up. Added executing a ping/pong command after the connect() command to ensure mongo is still/really up. --- awx/fact/utils/connection.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/awx/fact/utils/connection.py b/awx/fact/utils/connection.py index 75fe897b3b..4ea5f23bd1 100644 --- a/awx/fact/utils/connection.py +++ b/awx/fact/utils/connection.py @@ -4,6 +4,7 @@ from django.conf import settings from mongoengine import connect from mongoengine.connection import ConnectionError +from pymongo.errors import AutoReconnect def test_mongo_connection(): # Connect to Mongo @@ -14,13 +15,14 @@ def test_mongo_connection(): raise ConnectionError # Attempt to connect to the MongoDB database. - connect(settings.MONGO_DB, - host=settings.MONGO_HOST, - port=int(settings.MONGO_PORT), - username=settings.MONGO_USERNAME, - password=settings.MONGO_PASSWORD, - tz_aware=settings.USE_TZ) + db = connect(settings.MONGO_DB, + host=settings.MONGO_HOST, + port=int(settings.MONGO_PORT), + username=settings.MONGO_USERNAME, + password=settings.MONGO_PASSWORD, + tz_aware=settings.USE_TZ) + db[settings.MONGO_DB].command('ping') return True - except ConnectionError: + except ConnectionError, AutoReconnect: return False From 667d8a266744937adfe23f92f220a9f459dbf000 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 7 Dec 2015 13:48:19 -0500 Subject: [PATCH 21/21] fix the connection check fix * Multiple exceptions in except should be a tuple. Otherwise, the second parameter will be the error object. Apposed to the intent, for it to be another exception in a list of exceptions. --- awx/fact/utils/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/fact/utils/connection.py b/awx/fact/utils/connection.py index 4ea5f23bd1..4c4019e24d 100644 --- a/awx/fact/utils/connection.py +++ b/awx/fact/utils/connection.py @@ -23,6 +23,6 @@ def test_mongo_connection(): tz_aware=settings.USE_TZ) db[settings.MONGO_DB].command('ping') return True - except ConnectionError, AutoReconnect: + except (ConnectionError, AutoReconnect): return False