Commit Graph

37 Commits

Author SHA1 Message Date
Elijah DeLee
604cbc1737 Consume control capacity (#11665)
* Select control node before start task

Consume capacity on control nodes for controlling tasks and consider
remainging capacity on control nodes before selecting them.

This depends on the requirement that control and hybrid nodes should all
be in the instance group named 'controlplane'. Many tests do not satisfy that
requirement. I'll update the tests in another commit.

* update tests to use controlplane

We don't start any tasks if we don't have a controlplane instance group

Due to updates to fixtures, update tests to set node type and capacity
explicitly so they get expected result.

* Fixes for accounting of control capacity consumed

Update method is used to account for currently consumed capacity for
instance groups in the in-memory capacity tracking data structure we initialize in
after_lock_init and then update via calculate_capacity_consumed (both in
task_manager.py)

Also update fit_task_to_instance to consider control impact on instances

Trust that these functions do the right thing looking for a
node with capacity, and cut out redundant check for the whole group's
capacity per Alan's reccomendation.

* Refactor now redundant code

Deal with control type tasks before we loop over the preferred instance
groups, which cuts out the need for some redundant logic.

Also, fix a bug where I was missing assigning the execution node in one case!

* set job explanation on tasks that need capacity

move the job explanation for jobs that need capacity to a function
so we can re-use it in the three places we need it.

* project updates always run on the controlplane

Instance group ordering makes no sense on project updates because they
always need to run on the control plane.

Also, since hybrid nodes should always run the control processes for the
jobs running on them as execution nodes, account for this when looking for a
execution node.

* fix misleading message

the variables and wording were both misleading, fix to be more accurate
description in the two different cases where this log may be emitted.

* use settings correctly

use settings.DEFAULT_CONTROL_PLANE_QUEUE_NAME instead of a hardcoded
name
cache the controlplane_ig object during the after lock init to avoid
an uneccesary query
eliminate mistakenly duplicated AWX_CONTROL_PLANE_TASK_IMPACT and use
only AWX_CONTROL_NODE_TASK_IMPACT

* add test for control capacity consumption

add test to verify that when there are 2 jobs and only capacity for one
that one will move into waiting and the other stays in pending

* add test for hybrid node capacity consumption

assert that the hybrid node is used for both control and execution and
capacity is deducted correctly

* add test for task.capacity_type = control

Test that control type tasks have the right capacity consumed and
get assigned to the right instance group

Also fix lint in the tests

* jobs_running not accurate for control nodes

We can either NOT use "idle instances" for control nodes, or we need
to update the jobs_running property on the Instance model to count
jobs where the node is the controller_node.

I didn't do that because it may be an expensive query, and it would be
hard to make it match with jobs_running on the InstanceGroup which
filters on tasks assigned to the instance group.

This change chooses to stop considering "idle" control nodes an option,
since we can't acurrately identify them.

The way things are without any change, is we are continuing to over consume capacity on control nodes
because this method sees all control nodes as "idle" at the beginning
of the task manager run, and then only counts jobs started in that run
in the in-memory tracking. So jobs which last over a number of task
manager runs build up consuming capacity, which is accurately reported
via Instance.consumed_capacity

* Reduce default task impact for control nodes

This is something we can experiment with as far as what users
want at install time, but start with just 1 for now.

* update capacity docs

Describe usage of the new setting and the concept of control impact.

Co-authored-by: Alan Rominger <arominge@redhat.com>
Co-authored-by: Rebeccah <rhunter@redhat.com>
2022-02-14 10:13:22 -05:00
Ryan Petrello
c2ef0a6500 move code linting to a stricter pep8-esque auto-formatting tool, black 2021-03-23 09:39:58 -04:00
beeankha
479ab8550d Fix misc. linter errors 2020-05-14 15:43:50 -04:00
Christian Adams
a899a147e1 Fix new flake8 from pyflakes 2.2.0 release 2020-04-20 09:50:50 -04:00
Jeff Bradberry
82a0dc0024 Cycle or unset the webhook key if the webhook service changes
Also, tests.
2019-09-30 13:26:03 -04:00
Ryan Petrello
daeeaf413a clean up unnecessary usage of the six library (awx only supports py3) 2019-01-25 00:19:48 -05:00
cclauss
c371b869dc basestring to six.string_types for Python 3 2018-02-09 16:28:36 +01:00
Matthew Jones
d9e774c4b6 Updates for automatic triggering of policies
* Switch policy router queue to not be "tower" so that we don't
  fall into a chicken/egg scenario
* Show fixed policy list in serializer so a user can determine if
  an instance is manually managed
* Change IG membership mixin to not directly handle applying topology
  changes. Instead it just makes sure the policy instance list is
  accurate
* Add create/delete hooks for instances and groups to trigger policy
  re-evaluation
* Update policy algorithm for fairer distribution
* Fix an issue where CELERY_ROUTES wasn't renamed after celery/django
  upgrade
* Update unit tests to be more explicit
* Update count calculations used by algorithm to only consider
  non-manual instances
* Adding unit tests and fixture
* Don't propagate logging messages from awx.main.tasks and
  awx.main.scheduler
* Use advisory lock to prevent policy eval conflicts
* Allow updating instance groups from view
2018-02-01 16:56:16 -05:00
Chris Meyers
1d0e125aad make password survey field behave like text field
related to https://github.com/ansible/ansible-tower/issues/6083
2017-07-27 12:57:31 -04:00
Matthew Jones
5508bad97c Updating unit tests for task manager refactoring
* Purging old task manager unit tests
* Migrating those tests to functional tests
* Updating fixtures and factories to support a change in the way the
  task manager is tested
* Fix an issue with the mk_credential fixture when used in functional
  tests. Previously it had trouble with multiplel invocations when
  persistence was used
2017-05-10 12:45:37 -04:00
Matthew Jones
e1e83598e9 Merge branch 'release_3.1.3' into devel
* release_3.1.3: (52 commits)
  ack fact scan messages
  making ldap user/group search fields into codemirror instances
  removing UI parsing for LDAP User and Group Search fields
  Allow exception view to accept all valid HTTP methods.
  Restore ability of parsing extra_vars string for provisioning callback.
  Fix up backup/restore role broken in f7a8e45809758322d9ee41c5305850dd70ed5faf
  Stop / start ansible-tower-service during restores
  value_to_python should encode lookup fields as ascii
  fix brace interpolation on standard out pane
  Adjust some hardcoded usages of 'awx' to use 'aw_user' and 'aw_group'.
  Pull Spanish updates from Zanata
  Temporarily grant awx user createdb role
  Stop giving ownership of backups to postgres
  don't display chunked lines'
  Add dropdown li truncation with ellipsis
  CTiT -> adhoc modules should allow the user to add new modules
  Remove task that was replacing the supervisor systemd tmp file
  Fix failing supervisorctl commands on RH-based distros
  Give ownership of the supervisor socket to awx
  Setting for external log emissions cert verification
  ...
2017-04-28 13:57:04 -04:00
Ryan Petrello
ba259e0ad4 Introduce a new CredentialTemplate model
Credentials now have a required CredentialType, which defines inputs
(i.e., username, password) and injectors (i.e., assign the username to
SOME_ENV_VARIABLE at job runtime)

This commit only implements the model changes necessary to support the
new inputs model, and includes code for the credential serializer that
allows backwards-compatible support for /api/v1/credentials/; tasks.py
still needs to be updated to actually respect CredentialType injectors.

This change *will* break the UI for credentials (because it needs to be
updated to use the new v2 endpoint).

see: #5877
see: #5876
see: #5805
2017-04-21 15:42:26 -04:00
AlanCoding
b9c45ed54a Fix bug where API assumed survey choices were list
Applies to both single-select and multi-select type questions.
UI sends choices in the form of text with line breaks
separating the options.
Customer complained about empty string erronously sent by
the UI being passed to playbook, which is a component of this.
2017-04-07 09:03:45 -04:00
Matthew Jones
cb82809f10 Merge pull request #3935 from jladdjr/at-3532-typo
Minor typo fix (pointing workflow node template at unsupported unified job template)
2016-11-18 15:45:34 -05:00
Aaron Tan
9e4655419e Fix flake8 E302 errors. 2016-11-15 20:59:39 -05:00
Jim Ladd
20840b9867 Fix all instances of can not 2016-11-09 17:03:25 -05:00
AlanCoding
9acd50b8f3 inject WF node prompts into new jobs, new workflow RBAC tests 2016-09-21 16:04:43 -04:00
Chris Meyers
32461574ae add unit tests 2016-09-13 15:24:20 -04:00
Chris Meyers
4dc5c33442 refactor to be more testable 2016-09-12 12:19:36 -04:00
Chris Meyers
e4025a7eff flake8 fixes 2016-09-08 14:26:30 -04:00
Chris Meyers
39ac2c047b launch workflows 2016-09-01 14:11:20 -04:00
Chris Meyers
4c876b40e4 initial models and endpoints added for workflows 2016-08-30 15:05:28 -04:00
AlanCoding
ffc0b05a80 fix non-sensitive change becoming sensitive, add network cred in JT can_change 2016-06-14 12:20:02 -04:00
AlanCoding
a431f16953 job template creation to require use_role, include network creds 2016-06-10 10:58:27 -04:00
AlanCoding
04b8eb4eaf add mk_job to factories, use with survey passwords 2016-06-08 13:43:19 -04:00
Wayne Witzel III
8f3c0ff884 refactoring survey spec tests and fixtures 2016-06-06 13:39:25 -04:00
Wayne Witzel III
e6c76d0941 fixup objects creation helpers 2016-05-26 15:45:14 -04:00
Wayne Witzel III
2e0686a173 tests for object2 type when it is a role 2016-05-26 15:45:12 -04:00
Wayne Witzel III
ec505f3f60 adjusting test and renaming helper 2016-05-26 11:02:07 -04:00
Wayne Witzel III
2052f93792 fixing function calls and None handling 2016-05-26 11:02:02 -04:00
Wayne Witzel III
c514cd44c3 restructure factories/fixtures and fix tests 2016-05-26 11:01:58 -04:00
Wayne Witzel III
fa010c2228 fix mk_label method 2016-05-26 11:01:57 -04:00
Wayne Witzel III
aaabc2582d refactored roles handling and added some more tests 2016-05-26 11:01:55 -04:00
Wayne Witzel III
73e41ef6cc flake8 fixes 2016-05-26 11:01:52 -04:00
Wayne Witzel III
7ab385524d added roles support for organization_factory 2016-05-26 11:01:46 -04:00
Wayne Witzel III
becce311fe cleanup make methods and update asserts 2016-05-26 11:01:44 -04:00
Wayne Witzel III
0516ef02ca adding new factories 2016-05-26 11:01:39 -04:00