Implement automatic retry for LDAP errors
This commit is contained in:
parent
bdcd16b7e7
commit
99c80f5759
1 changed files with 10 additions and 9 deletions
|
@ -14,13 +14,14 @@ from celery.exceptions import Reject
|
||||||
from celery.utils.log import get_task_logger
|
from celery.utils.log import get_task_logger
|
||||||
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
from django.db.utils import Error as DjangoDBUtilsError
|
||||||
|
|
||||||
from ldapentities.models import LdapGroup, LdapUser
|
from ldapentities.models import LdapGroup, LdapUser
|
||||||
|
|
||||||
_LOGGER = get_task_logger(__name__)
|
_LOGGER = get_task_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def create_ldap_group(groupname, gid, description):
|
def create_ldap_group(groupname, gid, description):
|
||||||
"""
|
"""
|
||||||
This task creates an :py:class:`LDAP group <ldapentities.models.LdapGroup>`
|
This task creates an :py:class:`LDAP group <ldapentities.models.LdapGroup>`
|
||||||
|
@ -58,7 +59,7 @@ def create_ldap_group(groupname, gid, description):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def create_ldap_user(username, uid, gid, gecos, homedir, shell, password):
|
def create_ldap_user(username, uid, gid, gecos, homedir, shell, password):
|
||||||
"""
|
"""
|
||||||
This task creates an :py:class:`LDAP user <ldapentities.models.LdapUser>`
|
This task creates an :py:class:`LDAP user <ldapentities.models.LdapUser>`
|
||||||
|
@ -129,7 +130,7 @@ def create_ldap_user(username, uid, gid, gecos, homedir, shell, password):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def set_ldap_user_password(username, password):
|
def set_ldap_user_password(username, password):
|
||||||
"""
|
"""
|
||||||
This task sets the password of an existing :py:class:`LDAP user
|
This task sets the password of an existing :py:class:`LDAP user
|
||||||
|
@ -156,7 +157,7 @@ def set_ldap_user_password(username, password):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
@shared_task(bind=True)
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def add_ldap_user_to_group(self, username, groupname):
|
def add_ldap_user_to_group(self, username, groupname):
|
||||||
"""
|
"""
|
||||||
This task adds the specified user to the given group.
|
This task adds the specified user to the given group.
|
||||||
|
@ -201,7 +202,7 @@ def add_ldap_user_to_group(self, username, groupname):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def remove_ldap_user_from_group(username, groupname):
|
def remove_ldap_user_from_group(username, groupname):
|
||||||
"""
|
"""
|
||||||
This task removes the given user from the given group.
|
This task removes the given user from the given group.
|
||||||
|
@ -239,7 +240,7 @@ def remove_ldap_user_from_group(username, groupname):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def delete_ldap_user(username, *args, **kwargs):
|
def delete_ldap_user(username, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
This task deletes the given user.
|
This task deletes the given user.
|
||||||
|
@ -287,7 +288,7 @@ def delete_ldap_user(username, *args, **kwargs):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def delete_ldap_user_chained(previous_result, *args, **kwargs):
|
def delete_ldap_user_chained(previous_result, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
This task deletes the given user.
|
This task deletes the given user.
|
||||||
|
@ -307,7 +308,7 @@ def delete_ldap_user_chained(previous_result, *args, **kwargs):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def delete_ldap_group_if_empty(groupname):
|
def delete_ldap_group_if_empty(groupname):
|
||||||
"""
|
"""
|
||||||
This task deletes the given group if it is empty.
|
This task deletes the given group if it is empty.
|
||||||
|
@ -339,7 +340,7 @@ def delete_ldap_group_if_empty(groupname):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
||||||
def delete_ldap_group(groupname):
|
def delete_ldap_group(groupname):
|
||||||
"""
|
"""
|
||||||
This task deletes the given group.
|
This task deletes the given group.
|
||||||
|
|
Loading…
Reference in a new issue