diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 993b2a7426..5becefc36a 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -4642,6 +4642,9 @@ class BulkJobLaunchSerializer(BaseSerializer): if requested_use_inventories or 'inventory' in attrs: self.check_inventory_permission(attrs, request, requested_use_inventories) + if requested_use_credentials: + self.check_credential_permission(request, requested_use_credentials) + if requested_use_labels: self.check_label_permission(request, requested_use_labels) @@ -4649,7 +4652,8 @@ class BulkJobLaunchSerializer(BaseSerializer): self.check_instance_group_permission(request, requested_use_instance_groups) if requested_use_execution_environments: - self.check_instance_group_permission(request, requested_use_instance_groups) + self.check_execution_environment_permission(request, requested_use_instance_groups) + # all of the unified job templates and related items have now been checked, we can now grab the objects from the DB jobs_object = self.get_objectified_jobs( @@ -4814,6 +4818,8 @@ class BulkJobLaunchSerializer(BaseSerializer): if requested_use_instance_groups - accessible_use_instance_groups: not_allowed = requested_use_instance_groups - accessible_use_instance_groups raise serializers.ValidationError(_(f"Instance Groups {not_allowed} not found or you don't have permissions to access it")) + else: + raise serializers.ValidationError(_(f"Instance Groups {requested_use_instance_groups} not found or you don't have permissions to access it")) def check_execution_environment_permission(self, request, requested_use_execution_environments): accessible_execution_env = { diff --git a/awx/main/conf.py b/awx/main/conf.py index 16a16c2e2a..f72e12fd0d 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -788,7 +788,7 @@ register( register( 'BULK_HOST_MAX_CREATE', field_class=fields.IntegerField, - default=1000, + default=100, label=_('Max number of hosts to allow to be created in a single bulk action'), help_text=_('Max number of hosts to allow to be created in a single bulk action'), category=_('Bulk Actions'), diff --git a/awx/main/tests/functional/test_bulk.py b/awx/main/tests/functional/test_bulk.py index 76359775e0..9698241998 100644 --- a/awx/main/tests/functional/test_bulk.py +++ b/awx/main/tests/functional/test_bulk.py @@ -10,7 +10,7 @@ from awx.main.scheduler import TaskManager @pytest.mark.django_db -@pytest.mark.parametrize('num_hosts, num_queries', [(9, 15), (99, 20), (999, 30)]) +@pytest.mark.parametrize('num_hosts, num_queries', [(9, 15), (99, 20)]) def test_bulk_host_create_num_queries(organization, inventory, post, get, user, num_hosts, num_queries, django_assert_max_num_queries): ''' If I am a... diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 67a73cf4cd..c0a5318638 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -136,7 +136,7 @@ SCHEDULE_MAX_JOBS = 10 BULK_JOB_MAX_LAUNCH = 100 # Maximum number of host that can be created in 1 bulk host create -BULK_HOST_MAX_CREATE = 1000 +BULK_HOST_MAX_CREATE = 100 SITE_ID = 1 diff --git a/docs/bulk_api.md b/docs/bulk_api.md index 1b00931931..002130d122 100644 --- a/docs/bulk_api.md +++ b/docs/bulk_api.md @@ -75,4 +75,4 @@ Following is an example of a post request at the /api/v2/bulk/host_create: The above will add 6 hosts in the inventory. -The maximum number of hosts allowed to be added is controlled by the setting `BULK_HOST_MAX_CREATE`. The default is 1,000 hosts. Additionally, nginx limits the maximum payload size, which is very likely when posting a large number of hosts in one request with variable data associated with them. The maximum payload size is 1MB unless overridden in your nginx config. +The maximum number of hosts allowed to be added is controlled by the setting `BULK_HOST_MAX_CREATE`. The default is 100 hosts. Additionally, nginx limits the maximum payload size, which is very likely when posting a large number of hosts in one request with variable data associated with them. The maximum payload size is 1MB unless overridden in your nginx config.