keystone/keystone
Lance Bragstad ebc3f805f2 Retry update_user when sqlalchemy raises StaleDataErrors
Keystone's update_user() method in the SQL driver processes a lot of
information about how to update users. This includes evaluating password
logic and authentication attempts for PSI-DSS. This logic is evaluated
after keystone pulls the user record from SQL and before it exits the
context manager, which performs the write.

When multiple clients are all updating the same user reference, it's
more likely they will see an HTTP 500 because of race conditions exiting
the context manager. The HTTP 500 is due to stale data when updating
password expiration for old passwords, which happens when setting a new
password for a user.

This commit attempts to handle that case more gracefully than throwing a
500 by detecting StaleDataErrors from sqlalchemy and retrying.  The
identity sql backend will retry the request for clients that have
stale data change from underneath them.

Conflicts:
      keystone/tests/unit/test_backend_sql.py due to import order
      differences between train and ussuri. Also adjust the expected log
      message since the method path is different compared to older
      releases, which have the driver name in them (e.g., Identity).

Change-Id: I75590c20e90170ed862f46f0de7d61c7810b5c90
Closes-Bug: 1885753
(cherry picked from commit ceae3566e8)
(cherry picked from commit f47e635b80)
(cherry picked from commit 5b7d4c80d4)
(cherry picked from commit 07d3a3d3ff)
(cherry picked from commit d4f48fc4e5)
(cherry picked from commit 328cf33aab)
(cherry picked from commit f36034c8a6)
(cherry picked from commit e828c6e3bb)
2021-09-21 17:52:37 +00:00
..
application_credential Fix security issues with EC2 credentials 2020-05-14 13:40:55 +00:00
assignment Delete system role assignments when deleting groups 2018-02-14 19:21:44 +00:00
auth Use keystone.common.provider_api for auth APIs 2018-02-02 22:07:29 +00:00
catalog Use keystone.common.provider_api for catalog APIs 2017-12-27 16:32:18 +00:00
cmd Ensure bootstrap handles multiple roles with the same name 2020-03-06 19:11:53 +00:00
common Make system tokens work with domain-specific drivers 2019-10-22 16:56:09 -07:00
conf Check timestamp of signed EC2 token request 2020-05-11 19:41:13 +00:00
contrib Fix security issues with EC2 credentials 2020-05-14 13:40:55 +00:00
credential Add cadf auditing to credentials 2020-05-27 12:04:05 -03:00
endpoint_policy Use keystone.common.provider_api for endpoint_policy APIs 2017-12-27 16:56:49 +00:00
federation Mapped Groups don't exist breaks WebSSO 2018-09-24 16:06:35 +00:00
identity Retry update_user when sqlalchemy raises StaleDataErrors 2021-09-21 17:52:37 +00:00
limit Expose unified limit APIs 2018-01-25 16:33:11 +08:00
locale Imported Translations from Zanata 2018-03-14 06:35:15 +00:00
middleware Implement system-scoped tokens 2018-01-23 23:33:43 +00:00
models Implement system-scoped tokens 2018-01-23 23:33:43 +00:00
oauth1 Remove all v2.0 APIs except the ec2tokens API 2018-02-06 23:12:55 +01:00
policy Use keystone.common.provider_api for policy APIs 2017-12-27 17:10:20 +00:00
resource Remove @expression from tags 2018-03-01 13:26:00 +00:00
revoke Remove all v2.0 APIs except the ec2tokens API 2018-02-06 23:12:55 +01:00
server Add limit provider 2018-01-25 15:45:44 +08:00
tests Retry update_user when sqlalchemy raises StaleDataErrors 2021-09-21 17:52:37 +00:00
token Fix security issues with EC2 credentials 2020-05-14 13:40:55 +00:00
trust Populate application credential data in token 2018-02-20 08:47:02 +01:00
version Remove all v2.0 APIs except the ec2tokens API 2018-02-06 23:12:55 +01:00
__init__.py Revert "Disable eventlet monkey-patching of DNS" 2013-05-10 10:24:48 -04:00
exception.py Impose limits on application credentials 2018-01-27 12:00:23 +01:00
i18n.py Update links in keystone 2017-09-12 15:18:13 +08:00
notifications.py Set initiator id as user_id for auth events 2019-03-19 10:54:25 +01:00