Commit Graph
100 Commits
Author SHA1 Message Date
Ryan Petrello 32ee9838af use the correct logger for the callback receiver
the callback receiver and dispatcher share several modules, so add logic
to use the correct logger
2019-03-15 08:09:47 -04:00
Ryan Petrello 50d8eb30e1 fix a failing test in the unit-test target used to generate swagger docs 2019-03-12 14:59:24 -04:00
Ryan Petrello 023fbc931d generate Swagger schemas as if view permissions didn't matter
this fixes several scenarios where certain POST endpoints don't show up
in our generated Swagger doc; /api/swagger is only
discoverable/accessible in the development environment where we generate
the schema
2019-03-11 21:26:32 -04:00
Ryan Petrello 13c05c68fc fix a few additional py3 issues
related: https://github.com/ansible/awx/issues/3329
2019-02-27 16:56:36 -05:00
Ryan Petrello 04622d5786 remove redbaron and update dependencies 2019-02-21 10:08:24 -05:00
Ryan Petrello b1a33869dc convey OpenStack verify_ssl defaults in the CredentialType schema 2019-02-20 09:02:48 -05:00
Ryan Petrello 43ca4526b1 define native CredentialType inputs/injectors in code, not in the DB
This has a few benefits:

1.  It makes adding new fields to built-in CredentialTypes _much_
    simpler.  In the past, we've had to write a migration every time we
    want to modify an existing type (changing a label/help text,
    changing options like the recent become_method changes) or
    when adding a new field entirely

2.  It paves the way for third party credential plugins support, where
    importable libraries will define their own source code-based schema
2019-02-19 10:22:26 -05:00
Ryan Petrello 1e4cd9ea8f document the SQL profiler 2019-02-15 16:34:34 -05:00
Ryan Petrello 954ccccbc5 fix a bug in the display of playbooks using serial or free strategy 2019-02-15 16:13:12 -05:00
Ryan Petrello 6f43875e80 record profile data in /var/log/tower, not /var/lib/awx 2019-02-15 14:34:55 -05:00
Ryan Petrello 4f83d44142 mark a workflow convergence error message for i18n 2019-02-14 15:55:20 -05:00
Ryan Petrello eed94b641e add a custom DB backend that provides system-level SQL profiling
run this command on _any_ node in an awx cluster:

$ awx-manage profile_sql --threshold=2.0 --minutes=1

...and for 1 minute, the timing for _every_ SQL query in _every_ awx
Python process that uses the Django ORM will be measured

queries that run longer than (in this example) 2 seconds will be
written to a per-process sqlite database in /var/lib/awx/profile, and
the file will contain an EXPLAIN VERBOSE for the query and the full
Python stack that led to that SQL query's execution (this includes not
just WSGI requests, but background processes like the runworker and
dispatcher)

$ awx-manage profile_sql --threshold=0

...can be used to disable profiling again (if you don't want to wait for
the minute to expire)
2019-02-14 15:04:46 -05:00
Ryan Petrello 9bebf3217e remove usage of import * and enforce F405 in our linter
import * is a scourge upon the earth
2019-02-13 17:10:33 -05:00
Ryan Petrello 2a94611801 fix /migrations_notran 2019-02-13 08:59:20 -05:00
Ryan Petrello e4eda3ef0d remove field size limit on adhoc limit
related: 4b669fb16d
2019-02-13 08:34:10 -05:00
Ryan Petrello e245e50ee4 optimize a slow query in inventory script generation
if we don't preload this column, Django needs it, and so it generates
one query per-host (!!!) to get it.  For large (10k+ host) inventories,
this is incredibly slow.

see: https://github.com/ansible/awx/issues/3214
2019-02-12 12:55:38 -05:00
Ryan Petrello 229e997e7e don't update parent event changed|failed in bulk (it's expensive) 2019-02-06 20:02:52 -05:00
Ryan Petrello a6b362e455 fix a subtle bug in ansible_facts lookup filtering 2019-02-06 11:02:47 -05:00
Ryan Petrello 5e84782b9c provide a better ansible-inventory fallback error message old ansibles
see: https://github.com/ansible/awx/issues/3139
2019-02-05 17:12:48 -05:00
Ryan Petrello bb5312f4fc prevent field lookups on Host.ansible_facts keys (it doesn't work)
under the hood, Host.ansible_facts is a postgres jsonb field which
performs match operations using the JSON containment operator (@>)

this operator _only_ works on exact matches on containment (i.e.,
"does the `ansible_distribution` jsonb value contain _this exact_ JSON
structure"):

SELECT ...
FROM main_host
WHERE ansible_facts @> '{"ansible_distribution": "centos"}'

SELECT ...
FROM main_host
WHERE ansible_facts @> '{"packages": {"dnsmasq": [{"version": 2}]}}'

postgres does _not_ expose any operator for fuzzy or lookup-based
matches with this operator, so host filter values like these don't
really make sense (postgres can't _filter_ in the way intended in these
examples):

ansible_distribution__startswith=\"Cent\"
ansible_distribution__icontains=\"CentOS\"
ansible_facts__packages__dnsmasq[]__version__startswith=\"2\"
2019-02-05 10:43:51 -05:00
Ryan Petrello 10945faba1 properly detect ansible-playbook vs ansible runs in bwrap arg building
a recent change (65641c7) made it so that we call
ansible-playbook using its _absolute path_ (i.e.,
/usr/bin/ansible-playbook, /var/lib/venv/xyz/bin/ansible-playbook), so
this logic is no longer correct
2019-01-31 11:06:50 -05:00
Ryan Petrello d10d5f1539 work around a bug in Django that breaks the stdout HTML view in py3
see: https://github.com/ansible/awx/issues/3108
2019-01-31 01:01:40 -05:00
Ryan Petrello 1eeffe4ae2 remove awx-manage migrate_to_database_settings 2019-01-30 12:23:36 -05:00
Ryan Petrello 2927803a82 fix overindent lint failures 2019-01-30 12:12:39 -05:00
Ryan Petrello 88eaf1154a move awx.main.utils.ansible tests data into the correct location 2019-01-25 11:11:12 -05:00
Ryan Petrello daeeaf413a clean up unnecessary usage of the six library (awx only supports py3) 2019-01-25 00:19:48 -05:00
Ryan Petrello 4707dc2a05 clean up some unnecessary dispatcher reaping code 2019-01-24 11:11:05 -05:00
Ryan Petrello 9817ab14d0 clean up some minor linting issues 2019-01-24 10:23:56 -05:00
Ryan Petrello 0e5e23372d use the correct ansible-inventory executable for custom venvs 2019-01-23 14:07:48 -05:00
Ryan Petrello f7bc8fb662 record the virtualenv used when a job or inventory sync runs
see: https://github.com/ansible/awx/issues/2264
2019-01-23 11:48:06 -05:00
Ryan Petrello b2442d42a3 detect dead DB connections in the dispatcher when reaping jobs 2019-01-22 08:40:26 -05:00
Ryan Petrello 8cb8e63db5 fix a py3 bug that breaks the SSO complete endpoint 2019-01-21 17:04:13 -05:00
Ryan Petrello caa55f112f add robust handling of non-UTF8 when detecting inventory/playbooks 2019-01-19 13:25:41 -05:00
Ryan Petrello e45e4b3cda fix a deadlock when Python garbage collects LDAPBackend objects
we shouldn't call signal.disconnect in __del__ because it can lead to
deadlocks in Django signal dispatch code

The Signal.connect, Signal.disconnect, and Signal._live_receivers
methods all share a threading.Lock():

https://github.com/django/django/blob/22a60f8d0b331bf06c066ccba4eea5bb5e4ac9f2/django/dispatch/dispatcher.py#L49

It's possible for this to lead to a deadlock:

1.  Have code that calls Signal._live_receivers and enter the critical
    path inside the shared threading.Lock()
2.  Python garbage collection occurs and finds one or more LDAPBackend
    objects with no more references
3.  This __del__ is called, which calls Signal.disconnect
4.  Code in Signal._disconnect attempts to obtain the (already held)
    threading.Lock
5.  Python hangs forever while attempting to garbage collect
2019-01-18 11:27:50 -05:00
Ryan Petrello 65641c7edd add support for custom py3 ansible virtualenvs 2019-01-18 10:55:53 -05:00
Ryan Petrello 37dbfa88f9 close the persistent shelve when we're done checking it
this code was added to detect celerybeat shelve .db corruption, but it caused a different issue; opening the shelve in this way puts a write lock on it, which means that when we attempt to open it _again_ moments later, we can't.

when we're done checking the validity of the file, we need to close it
2019-01-17 08:20:21 -05:00
Ryan Petrello 6d04bd34ce enforce key order when writing swagger docs JSON 2019-01-16 16:00:27 -05:00
Ryan Petrello 33c1416f6c work around a py3 bug in celerybeat 2019-01-15 15:19:02 -05:00
Ryan Petrello 3d7fcb3835 fix a few isolated issues related to the py2 -> py3 move 2019-01-15 14:09:05 -05:00
Ryan Petrello 2016798e0f fix a few UTF-8 bugs on Ubuntu related to stdout text downloads 2019-01-15 14:09:05 -05:00
Ryan Petrello 39d119534c support isolated runs in py2 *and* py3 (for now)
once we merge in runner support for isolated environments, we can
revert this commit (because we'll always run isolated code using python3
executables)
2019-01-15 14:09:05 -05:00
Ryan Petrello 96b9bd6ab6 make py3 packaging work for k8s 2019-01-15 14:09:05 -05:00
Ryan Petrello af4234556e remove dm.xmlsec.binding
python-saml uses dm.xmlsec.binding only supports python2
by moving to py3, we now use python3-saml (which uses python-xmlsec
instead)

see: https://github.com/onelogin/python-saml/issues/145#issuecomment-222021691
2019-01-15 14:09:05 -05:00
Ryan Petrello c6482137d1 parametrize PYTHON for Ubuntu py35 support 2019-01-15 14:09:05 -05:00
Ryan Petrello f223df303f convert py2 -> py3 2019-01-15 14:09:01 -05:00
Ryan Petrello f132ce9b64 switch image builds to py3 2019-01-15 13:25:13 -05:00
Ryan Petrello 32c14d6eab catch _all_ types of django.db.utils.Error on CTinT key lookups 2019-01-11 08:49:47 -05:00
Ryan Petrello 4858868428 configure an HA policy for openshift/k8s installs 2018-12-14 14:08:30 -05:00
Ryan Petrello 5950f26c69 only allow the task dispatch worker to import and run decorated tasks
this _technically_ prevents a remote code exploit where a user who has
access to publish AMQP messages to the dispatch queue could craft
a special message that would import and run arbitrary Python functions;
that said, the types of user with this privilege level are generally
_already_ the awx user (so they can already do this by hand if they
want)
2018-12-12 17:46:41 -05:00
Ryan Petrello c2660af60d stop various async background requests from bumping the session expiry
if a user has an active session that just sits on the dashboard or job
list, websocket messages that come in (for e.g., job status changes)
will trigger AJAX requests for more data; this process causes a user
with an idle login to continue to generate API requests, which in turn
ticks their expiry timer.  As a result, users with active sessions
sitting on these two (popular) pages will never be automatically logged
out via SESSION_MAX_AGE.

this change introduces a special header that the UI can use to signify
that a request shouldn't bump the expiry timer
2018-12-11 09:15:58 -05:00
Ryan Petrello 7252883094 allow encrypted fields in custom credentials to be empty 2018-11-30 14:07:56 -05:00
Ryan Petrello c90d81b914 resolve a nuanced traceback for JTs that run w/ a failed project
related: https://github.com/ansible/awx/pull/2719
2018-11-29 17:10:23 -05:00
Ryan Petrello 0391dbc292 add additional DB retry logic to the callback receiver
initially, I implemented this for _only_ the task worker, but it's
probably needed for callback event workers, too
2018-11-29 11:57:46 -05:00
Ryan Petrello fcb6ce2907 remove a few deprecated awx-manage commands 2018-11-29 10:09:57 -05:00
Ryan Petrello 38bf174bda don't reap jobs that aren't running
this is a simple sanity check, but it should help us avoid shooting
ourselves in the foot in complicated scenarios, such as:

1.  A dispatcher worker is running a job, and it's killed with `kill -9`
2.  The dispatcher attempts to reap jobs with a matching celery_task_id
3.  The associated sync project update has the *same* celery_task_id
    (an implementation detail of how we implemented that), and it ends
    up getting reaped _even though_ it's already finished and has
    status=successful
2018-11-28 18:11:12 -05:00
Ryan Petrello 1ac5bc5e2b remove angular-md5 license 2018-11-28 10:43:53 -05:00
Ryan Petrello a72f3d2f2f generate host_config_key using random UUIDs, not a time-based md5 hash 2018-11-28 10:43:45 -05:00
Ryan Petrello a810aaf319 fix isolated nodes in the dev environment 2018-11-28 09:54:39 -05:00
Ryan Petrello 4e45c3a66c mock an HTTP call to fix busted unit tests 2018-11-28 09:17:50 -05:00
Ryan Petrello b1bd87bcd2 raise contrast on a few key page elements to pass WCAG contrast checks 2018-11-27 10:20:24 -05:00
Ryan Petrello d5c6c589b2 add an AWX_ISOLATED_VERBOSITY setting for debugging isolated connections 2018-11-26 23:47:16 -05:00
Ryan Petrello fc0a039097 collect isolated capacity using a cache plugin, not stdout parsing
reading capacity values using the jsonfile cache plugin is more robust
in scenarios where ansible-playbook may print non-JSON output (such as
-vvv or when a custom callback plugin like timer is enabled)
2018-11-26 17:08:42 -05:00
Ryan Petrello 32e7ddd43a only override django for FIPS in environments where Django is installed
isolated awx installs don't have this tooling, and so they don't need
this specific monkey-patch
2018-11-26 09:17:48 -05:00
Ryan Petrello b4f906ceb1 add dispatcher status to the sosreport 2018-11-20 12:12:02 -05:00
Ryan Petrello 9e2f4cff08 remove the x icon on the session timeout modal (it doesn't work) 2018-11-19 14:37:49 -05:00
Ryan Petrello e36335f68c only send activity stream create for registered unified jobs
see https://github.com/ansible/awx/issues/2733
2018-11-19 09:44:12 -05:00
Ryan Petrello 661cc896a9 add a user agent for requests to Insights 2018-11-16 16:25:08 -05:00
Ryan Petrello 37234ca66e prevent the dispatcher from using a nonsensical max_workers value 2018-11-16 10:16:39 -05:00
Ryan Petrello d3dc126d45 truncate user first/last name if it exceeds 30 chars on LDAP auth 2018-11-14 15:51:43 -05:00
Ryan Petrello 49f4ed10ca include M2M labels and credentials in Job creation activity stream 2018-11-14 10:36:01 -05:00
Ryan Petrello a3f9c0b012 warn about FIPS mode if the Django version changes 2018-11-13 15:04:36 -05:00
Ryan Petrello cceac8d907 support PKCS8-formatted keys to enable FIPS compliance
see: https://access.redhat.com/solutions/1519083
2018-11-12 16:21:57 -05:00
Ryan Petrello 10667fc855 fix an unbound variable
see: https://github.com/ansible/awx/issues/2642j
2018-11-08 15:14:47 -05:00
Ryan Petrello 001bd4ca59 resolve a few token revocation issues, and add tests 2018-11-08 08:15:24 -05:00
Ryan Petrello 28cd762dd7 properly validate cert data that happens to contain an END substring 2018-11-06 15:57:35 -05:00
Ryan Petrello 1523feee91 send activity stream changes as raw JSON, not a JSON-ified string
see: https://github.com/ansible/awx/issues/2005
2018-11-06 14:28:57 -05:00
Ryan Petrello 05156a5991 move from GEC_PEM_FILE_PATH to GCE_CREDENTIALS_FILE_PATH 2018-11-05 15:44:31 -05:00
Ryan Petrello a748a272fb Merge remote-tracking branch 'tower/release_3.3.1' into devel 2018-11-01 12:07:02 -04:00
Ryan Petrello 479448ff09 remove an old, unused migration file 2018-10-31 11:15:09 -04:00
Ryan Petrello a1012b365c pin docker-compose to a working version 2018-10-31 10:47:45 -04:00
Ryan Petrello 28512e042b remove DeprecatedAuthTokenMiddleware 2018-10-26 10:11:53 -04:00
Ryan Petrello c695ba2e10 fix flake8 2018-10-24 10:11:53 -04:00
Ryan Petrello 3b7336c570 drop old celery/djcelery tables we no longer need 2018-10-22 09:20:10 -04:00
Ryan Petrello 9316c9ea3e implement simple retries for wayward inventory deletes 2018-10-19 10:10:52 -04:00
Ryan Petrello 3be9113d6b fix a bug that breaks job cancel on single node jobs
1.  Install awx w/ a single node.
2.  Start a long-running job.
3.  Forcibly kill the `awx-manage run_dispatcher` process (e.g.,
    SIGKILL) and do not start it again.
4.  The job remains in running - without a second cluster to discover
    the job, it is never reaped.
5.  This PR allows you to cancel the job from the UI+API.
2018-10-19 09:10:33 -04:00
Ryan Petrello 0d29bbfdc6 make the dispatcher more fault-tolerant to prolonged database outages 2018-10-18 20:00:07 -04:00
Ryan Petrello 53ae05094e use the proper logger for the callback receiver 2018-10-17 10:56:29 -04:00
Ryan Petrello 79002ae563 upgrade to the latest kombu + celery 2018-10-16 16:14:58 -04:00
Ryan Petrello 6e4f3efc4b silence the noisy error that's printed w/ awx-manage check_migrations 2018-10-16 13:48:03 -04:00
Ryan Petrello 6ff1fe8548 allow users to specify BROKER_URL with passwords that contain : and @ 2018-10-16 11:56:57 -04:00
Ryan Petrello f3e73bbed8 don't call rabbitmqctl forget_cluster_node for isolated instances 2018-10-16 09:47:53 -04:00
Ryan Petrello 00cae104b3 remove over-eager survey choices validation
it looks like choices can also be a list and _maybe_ comma delimited;
clearly there's a lot of history here; let's verify and test what's _really_ supported and _then_ add any necessary validation
2018-10-15 16:40:17 -04:00
Ryan Petrello 720a634702 don't attempt to recover special QUIT messages in the worker pool
when `--reload` is sent to the dispatcher, it sends a special QUIT
message to each worker in the pool so that it will exit gracefully at
the next opportunity

when a worker process exits unexpectedly, the dispatcher attempts to
recover its queued messages and sends them to another worker in the
pool; in this scenario, we should _never_ re-enqueue these special
QUIT messages (because the process doesn't need to quit, it's already
gone)

To reproduce this race condition:

1.  Launch an adhoc that does `sleep 60`
2.  Run `awx-manage run_dispatcher --reload` to enqueue a `QUIT` message
    into the worker's queue
3.  Find the pid of the worker running the `sleep 60` and `SIGKILL` it.
4.  Observe that dispatcher attempts to requeue the `QUIT` message and
    logs a confusing error.
2018-10-15 12:17:52 -04:00
Ryan Petrello 9d81727d16 fix a typo on the JT add page that breaks the custom venv field 2018-10-15 11:19:58 -04:00
Ryan Petrello 011c8ae822 fix a typo on the JT add page that breaks the custom venv field 2018-10-15 11:04:31 -04:00
Ryan Petrello 867ff5da71 minor nit for https://github.com/ansible/tower/pull/3060 2018-10-12 16:17:14 -04:00
Ryan Petrello d4e3127fb4 properly handle AnsibleVaultEncryptedUnicode objects in the callback 2018-10-12 12:29:46 -04:00
Ryan Petrello ac80bc874a more shippable -> zuul cleanup 2018-10-12 11:50:29 -04:00
Ryan Petrello 517043e209 update to the latest stable 1.1 django-oauth-toolkit
see: https://github.com/jazzband/django-oauth-toolkit/pull/629
2018-10-12 10:21:57 -04:00
Ryan Petrello 1167361128 some minor README updates 2018-10-11 16:05:29 -04:00