Catch DBDuplicateEntry Error during cred_create
There might be some potential race condition for cred_create_update, this patch catch DBDuplicateEntry error during cred_create and then do cred_update. Existing unittest can cover this modification. Closes-Bug: #1567764 Change-Id: I655bc73af07b84af424488c9333c039aae9262e3
This commit is contained in:
parent
a83bc88156
commit
09ab723096
@ -19,6 +19,7 @@ import sys
|
||||
import threading
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import utils as sa_utils
|
||||
from oslo_log import log as logging
|
||||
@ -691,10 +692,9 @@ def cred_delete(context, user, project):
|
||||
|
||||
|
||||
def cred_create_update(context, values):
|
||||
cred = cred_get(context, values.get('user'), values.get('project'))
|
||||
if not cred:
|
||||
try:
|
||||
return cred_create(context, values)
|
||||
else:
|
||||
except db_exc.DBDuplicateEntry:
|
||||
user = values.pop('user')
|
||||
project = values.pop('project')
|
||||
return cred_update(context, user, project, values)
|
||||
|
Loading…
Reference in New Issue
Block a user