Commit Graph

41 Commits

Author SHA1 Message Date
dandds
05f6b36ece Update SQL query to find pending portfolios.
The query to find portfolios that are pending provisioning is updated to
check for:

- a period of performance that has started
- a portfolio state machine that has an UNSTARTED or one of the CREATED
  states

I left several TODOs to ensure that the orchestration functions
correctly for portfolio.
2020-02-04 10:16:02 -05:00
dandds
6b8d9d1d65 Celery wrapper for creating a user. 2020-02-02 14:42:44 -05:00
dandds
cc28f53999 Function for claiming multiple resources at once.
Like claim_for_update, the claim_many_for_update claims resources with
an expiring lock. This was written to allow the updating of multiple
application roles with a single cloud_id, since multiple application
roles will map to a single Azure Active Directory user.
2020-02-02 14:19:13 -05:00
dandds
8810a59e0a Orchestration for creating app management groups.
This adds:
- A Celery beat task for enqueuing application creation tasks
- A Celery task for creating the application
- Payload and Response dataclasses for creating management groups

It also does some incidental cleanup.
2020-01-26 12:23:33 -05:00
dandds
bfc0692063 Remove multiple job failure tables in favor of one.
We don't know yet how useful the job failue tables will be, and
maintaining multiple failure tables--one for every entity involved in
CSP provisioning--is burdensome. This collapses them all into a single
table that track the entity type (environment, portfolio, etc.) and the
entity ID. That way we can construct queries when needed to find task
results.
2020-01-25 15:50:01 -05:00
tomdds
d81d953c31 Fix formatting and some typos 2020-01-14 16:36:16 -05:00
Philip Kalinsky
69bd2f43a5 provision portfolio state machine 2020-01-14 16:36:16 -05:00
leigh-mil
17864cc060 Add migration to change environment_roles role column from string to
enum type.
Fix tests and functions affected by the column type change.
2020-01-14 13:12:29 -05:00
leigh-mil
e64900245d Remove baseline_info column from environments table 2019-10-30 14:46:33 -04:00
richard-dds
184b58d5d2 Remove AWSCloudProvider 2019-10-28 13:55:34 -04:00
richard-dds
6ea17bb4f8 Merge create_environment and create_environment_baseline 2019-10-28 13:39:40 -04:00
richard-dds
1bce0a1f01 Revert user deletion job 2019-10-14 16:51:19 -04:00
leigh-mil
10c16cc4ef Send email after environment is provisioned 2019-10-10 09:45:01 -04:00
richard-dds
ed7bc33e44 Set deleted flag in do_delete_user 2019-10-08 16:42:25 -04:00
richard-dds
343e989de8 Update comments 2019-10-08 16:42:25 -04:00
richard-dds
2ad30b5fa4 Implement dispatch_delete_user job 2019-10-08 16:42:25 -04:00
richard-dds
00f76ae5af Add delete user job 2019-10-08 16:42:25 -04:00
richard-dds
d60cc58dee Merge pull request #1083 from dod-ccpo/user-provisioning-task
Add create_user task
2019-09-24 13:50:17 -04:00
dandds
0d45be68d5 Adjust environment claim test to avoid race condition 2019-09-23 14:53:18 -04:00
richard-dds
399cf74ed6 Only provision EnvironmentRoles with active ApplicationRoles 2019-09-23 11:30:06 -04:00
richard-dds
4eee06ba44 Add test for do_provision_user 2019-09-20 11:43:19 -04:00
richard-dds
2fca542100 Implement dispatch query for provision_user 2019-09-20 11:37:18 -04:00
richard-dds
d1e146f577 Add create_user task 2019-09-19 16:56:36 -04:00
richard-dds
6c7667b7fc Filter out deleted envs in dispatch_create_environment 2019-09-19 14:24:39 -04:00
richard-dds
2fc7a0d460 Add small sleep to claims test to avoid random failures 2019-09-18 16:34:56 -04:00
richard-dds
343e5a52ac Use session.refresh in tests 2019-09-17 15:29:33 -04:00
richard-dds
3f072bac3c Remove unused users 2019-09-17 15:28:07 -04:00
richard-dds
ade7dc08fd Only fetch environment_id in provisioning queries 2019-09-17 15:27:03 -04:00
richard-dds
68ac7aecdf More test cleanup 2019-09-17 11:47:06 -04:00
richard-dds
23261da3af Use None isntead of sql.null 2019-09-17 11:15:25 -04:00
richard-dds
abeadee3f3 Claim resource only temporarily 2019-09-17 11:03:33 -04:00
richard-dds
945debe6ee Move claim_for_update to models.utils 2019-09-17 10:39:59 -04:00
richard-dds
67a2905d51 Make claim_for_update easier to follow 2019-09-16 17:03:57 -04:00
richard-dds
4624acd1c5 Remove unused import 2019-09-16 17:00:05 -04:00
richard-dds
2bbe974755 Implement simple locking system for environments 2019-09-16 16:39:37 -04:00
richard-dds
1a9c34d856 Fix and test environment dispatch tasks 2019-09-11 11:43:06 -04:00
richard-dds
4405ed91d5 Fix migration path 2019-09-11 11:42:36 -04:00
richard-dds
e3ea2d2fe5 Move "envs pending creation" query to Environments domain 2019-09-11 11:41:10 -04:00
richard-dds
4a5ca1cd27 Add query for environments pending creation 2019-09-11 11:41:10 -04:00
richard-dds
e9bf806dc6 Environment provisioning celery tasks
Failing test

Break env provisioning task into 3 separate tasks

Make env creation task idempotent

Test other env provisioning tasks

DRY tasks
2019-09-11 11:41:03 -04:00
dandds
7010bdb09c Record job failures with application context.
AT-AT needs to be able to track which user tasks failed and why. To
accomplish this we:

- Enabled Celery's results backend, which logs task results to a data
  store; a Postgres table, in our case.
  (https://docs.celeryproject.org/en/latest/userguide/tasks.html#result-backends)
- Created tables to track the relationships between the relevant models
  (Environment, EnvironmentRole) and their task failures.
- Added an `on_failure` hook that tasks can use. The hook will add
  records to the job failure tables.

Now a resource like an `Environment` has access to it task failures
through the corresponding failure table.

Notes:
- It might prove useful to use a real foreign key to the Celery results
  table eventually. I did not do it here because it requires that we
  explicitly store the Celery results table schema as a migration and
  add a model for it. In the current implementation, AT-AT can be
  agnostic about where the results live.
- We store the task results indefinitely, so it is important to specify
  tasks for which we do not care about the results (like `send_mail`)
  via the `ignore_result` kwarg.
2019-09-09 14:54:46 -04:00