diff --git a/rbac/management/cache.py b/rbac/management/cache.py index 68d93fcaf..af2f8a22b 100644 --- a/rbac/management/cache.py +++ b/rbac/management/cache.py @@ -195,30 +195,10 @@ def delete_all_policies_for_tenant(self): err_msg = f"Error deleting all policies for tenant {self.tenant}" with self.delete_handler(err_msg): logger.info("Deleting entire policy cache for tenant %s", self.tenant) - try: - key = self.key_for("*") - logger.info(f"value of key: {key}") - except Exception as e: - logger.error(f'error from key = self.key_for("*") with error message: {e}') - - keys = [] - try: - keys = self.connection.keys(key) - logger.info(f"Content of 'keys' variable: {keys}") - except Exception as e: - logger.error(f"error from keys = self.connection.keys(key): {e}") + keys = self.connection.keys(self.key_for("*")) if keys: - try: - self.connection.delete(*keys) - except Exception as e: - logger.error( - f"An exception occurred inside delete_all_policies_for_tenant() for tenant {self.tenant} " - f"withing line 'if keys': {e}" - ) - - logger.info(f"End of 'with self.delete_handler' for tenant {self.tenant}") - logger.info(f"End of 'delete_all_policies_for_tenant' for tenant {self.tenant}") + self.connection.delete(*keys) def save_policy(self, uuid, sub_key, policy): """Write the policy for a given user for a given sub_key (application_offset_limit) to Redis.""" diff --git a/rbac/management/management/commands/seeds.py b/rbac/management/management/commands/seeds.py index 22326bc48..8c6dc9933 100644 --- a/rbac/management/management/commands/seeds.py +++ b/rbac/management/management/commands/seeds.py @@ -53,8 +53,4 @@ def handle(self, *args, **options): group_seeding() logger.info("*** Group seeding completed. ***\n") - try: - purge_cache() - except Exception as e: - logger.error(f"An exception occurred during purge cache: {e}") - raise e + purge_cache() diff --git a/rbac/management/seeds.py b/rbac/management/seeds.py index 8db88dbbb..36906e99e 100644 --- a/rbac/management/seeds.py +++ b/rbac/management/seeds.py @@ -27,21 +27,9 @@ def on_complete(progress, tenant): """Explicitly close the connection for the thread.""" logger.info(f"Purging policy cache for tenant {tenant.org_id} [{progress}].") - try: - cache = AccessCache(tenant.org_id) - except Exception as e: - logger.error(f"An exception occurred inside on_complete() for line 1: {e}") - - try: - cache.delete_all_policies_for_tenant() - except Exception as e: - logger.error(f"An exception occurred inside on_complete() for line 2: {e}") - - try: - connections.close_all() - except Exception as e: - logger.error(f"An exception occurred inside on_complete() for line 3: {e}") - + cache = AccessCache(tenant.org_id) + cache.delete_all_policies_for_tenant() + connections.close_all() logger.info(f"Finished purging policy cache for tenant {tenant.org_id} [{progress}].") @@ -86,7 +74,4 @@ def purge_cache(): tenant_count = tenants.count() for idx, tenant in enumerate(list(tenants)): progress = f"[{idx + 1} of {tenant_count}]." - try: - executor.submit(on_complete, progress, tenant) - except Exception as e: - logger.error(f"An exception occurred inside purge_cache() for {tenant}: {e}") + executor.submit(on_complete, progress, tenant)