You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "MahmoudHassanen99 (via GitHub)" <gi...@apache.org> on 2026/08/02 18:59:44 UTC

Re: [PR] HDDS-15982. Fix UnsupportedOperationException and add idempotency to RangerClientMultiTenantAccessController [ozone]

MahmoudHassanen99 commented on code in PR #10872:
URL: https://github.com/apache/ozone/pull/10872#discussion_r3700048242


##########
hadoop-ozone/multitenancy-ranger/src/main/java/org/apache/hadoop/ozone/om/multitenant/RangerClientMultiTenantAccessController.java:
##########
@@ -313,6 +384,13 @@ public void deleteRole(String roleName) throws IOException {
     try {
       client.deleteRole(roleName, shortName, rangerServiceName);
     } catch (RangerServiceException e) {
+      // If the role does not exist, silently return.
+      // This makes tenant deletion tolerant of partial previous state,
+      // e.g. when one role was deleted but another was not.
+      if (isNotFoundException(e)) {

Review Comment:
   Hi @smengcl,
   
   Thanks for the feedback
   We agree with your point, swallowing duplicate creation errors to return success risks leaving mismatched policies in Ranger. That's why I've switched creation back to a fail-fast approach.
   
   We have updated the PR to remove generalized idempotency on creation while keeping tenant deletion safe.
   
   ### Summary of Changes in this PR:
   1. **Creation is Fail-Fast (`createPolicy` / `createRole`):** Removed duplicate error suppression. If a Ranger policy or role already exists, creation fails fast and aborts tenant provisioning cleanly to prevent policy mismatch.
   2. **Deletion is Idempotent (`deletePolicy` / `deleteRole`):** Retained the `isRoleNotFoundException` logic (handling Ranger's HTTP 400/404 response quirks for missing entities) strictly for `delete` calls. This guarantees tenant teardown is idempotent and won't block OM metadata cleanup if a Ranger entity is already gone.
   3. **Mutable Collections Fix:** Converted all lists in `toRangerPolicy` to `new ArrayList<>()` to fix `UnsupportedOperationException` issues with Ranger SDK calls.
   
   ### Local CLI Verification & Behavior Proof:
   * **OM Level Safety:** Verified that OM blocks duplicate tenant creation early at the metadata level (`TENANT_ALREADY_EXISTS`) before touching Ranger.
   * **Ranger Level Safety:** Verified that if a matching role/policy already exists in Ranger, the creation call fails fast with an explicit Ranger exception rather than returning a false-positive success over mismatched resources.
   * **Deletion Lifecycle:** Verified that deleting a tenant unlinks OM metadata and safely cleans up Ranger entities without throwing 400/404 errors if entities are missing.
   
   Any full, state-aware policy reconciliation for creation/updates will be handled in a dedicated follow-up Jira.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org