Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Place upper limit on tas user validation, remove selected identity notion #639

Merged
merged 19 commits into from
Sep 7, 2018

Conversation

cdosborn
Copy link
Contributor

@cdosborn cdosborn commented Jul 21, 2018

Description

This changeset places an upper limit on the tas api calls (5sec, in practice the average is about 0.6s), removes all references to selected identities, and makes the user validation and account creation explicit in api/v1/profile (originally the purview of select identity logic)

User validation and account creation happen as a side effect of the serialization of a user's "selected identity" in the api/v1/profile endpoint. Atmosphere used to have the notion of a selected identity for each user. A user's actions would occur against the cloud pointed to by their selected identity. In the frontend, the user would first select a cloud, before they could perform actions against it. All references to a selected identity are vestigial. In jetstream we discovered that changing a user's profile would sometimes take 10-15s, this occurred because the serialization of the selected_identity was checking if the user was valid by querying out to the TAS API. After checking that the user was valid, the service would make sure that the user had identities on all providers where they were permitted.

Depends on cyverse/clank#277

Checklist before merging Pull Requests

  • Add an entry in the changelog
  • Reviewed and approved by at least one other contributor.
  • New test(s) included to reproduce the bug/verify the feature
    • There are now tests which ensure create_new_accounts logic is preserved and that the offline validation works (fixed in f839f02)
  • New variables supported in Clank

@cdosborn cdosborn self-assigned this Jul 21, 2018
@cdosborn cdosborn changed the title No longer validate user and create accounts in api/v1/profile WIP - No longer validate user and create accounts in api/v1/profile Jul 21, 2018
@cdosborn cdosborn force-pushed the fix-account-creation branch 3 times, most recently from 55fbfdf to 3a8f9a1 Compare July 23, 2018 19:21
@coveralls
Copy link

coveralls commented Jul 23, 2018

Coverage Status

Coverage increased (+0.2%) to 37.827% when pulling 943d9b4 on cdosborn:fix-account-creation into 3587ea5 on cyverse:master.

@cdosborn cdosborn force-pushed the fix-account-creation branch 4 times, most recently from a1c851d to cd6aef3 Compare July 30, 2018 18:44
@cdosborn cdosborn changed the title WIP - No longer validate user and create accounts in api/v1/profile Place upper limit on tas user validation, remove selected identity notion Jul 31, 2018
@cdosborn cdosborn force-pushed the fix-account-creation branch 5 times, most recently from bf68037 to 802f35d Compare August 1, 2018 21:07
@julianpistorius
Copy link
Contributor

Thanks @cdosborn! I'd like to dig through this a bit more.

@cdosborn cdosborn force-pushed the fix-account-creation branch 5 times, most recently from 705c968 to 5f291b9 Compare August 2, 2018 23:22
Copy link
Contributor

@julianpistorius julianpistorius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdosborn Can you help me understand this one?

ea53272#diff-3f7bc33e5a66a692d2e802229596243dL184

Otherwise looks good. 👍

@@ -16,7 +16,8 @@ def tacc_api_post(url, post_data, username=None, password=None):
# logger.debug("REQ BODY: %s" % post_data)
resp = requests.post(
url, post_data,
auth=(username, password))
auth=(username, password),
timeout=5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that one day we will have to modify this in production in a hurry. Can we make this a setting with a default of 5 seconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i'll add that

@@ -181,7 +181,7 @@ def email_hash(self):
# Save Hooks Here:


def get_or_create_user_profile(sender, instance, created, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. What's going on here?

@cdosborn
Copy link
Contributor Author

cdosborn commented Aug 6, 2018

Just going to push this into the next release

@cdosborn
Copy link
Contributor Author

cdosborn commented Sep 6, 2018

@julianpistorius i'm tacking on some tests in a short bit

@cdosborn
Copy link
Contributor Author

cdosborn commented Sep 6, 2018

@julianpistorius This is being blocked by cyverse/clank#277, once that is 👍 the travis build should greenlight.

The tas api averages about 500ms, but occasionally goes to 3,5,10 sec. This
upperbound is to limit how long api/v1/profile will take in the worst case.
Creating new accounts and validation of the user occurred in a side effect of
the selcted_identity field of a serializer. These calls need to be made, but
should be more explicit. A selected_idenity is a relic from a time before.

An important side effect here is that PATCHs no longer create accounts or
check if the user is valid, greatly reducing the time to update a user's profile.

In addition, create_new_accounts shouldn't check whether it should actually do
its job, by calling user.is_valid first.
This is implementing what was mentioned in a TODO comment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants