-
Notifications
You must be signed in to change notification settings - Fork 629
HDDS-15462. Move ACL check in Volume requests to preExecute #10328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,13 +21,15 @@ | |
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.InvalidPathException; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import org.apache.hadoop.hdds.utils.db.cache.CacheKey; | ||
| import org.apache.hadoop.hdds.utils.db.cache.CacheValue; | ||
| import org.apache.hadoop.ozone.OzoneAcl; | ||
| import org.apache.hadoop.ozone.OzoneConsts; | ||
| import org.apache.hadoop.ozone.audit.AuditLogger; | ||
| import org.apache.hadoop.ozone.audit.OMAction; | ||
| import org.apache.hadoop.ozone.om.OMMetadataManager; | ||
| import org.apache.hadoop.ozone.om.OMMetrics; | ||
| import org.apache.hadoop.ozone.om.OzoneManager; | ||
|
|
@@ -53,6 +55,43 @@ public abstract class OMVolumeAclRequest extends OMVolumeRequest { | |
| omVolumeAclOp = aclOp; | ||
| } | ||
|
|
||
| @Override | ||
| public OzoneManagerProtocolProtos.OMRequest preExecute(OzoneManager ozoneManager) | ||
| throws IOException { | ||
| OzoneManagerProtocolProtos.OMRequest omRequest = super.preExecute(ozoneManager); | ||
|
|
||
| // ACL check during preExecute | ||
| if (ozoneManager.getAclsEnabled()) { | ||
| String volume = getVolumeName(); | ||
| try { | ||
| checkAcls(ozoneManager, OzoneObj.ResourceType.VOLUME, | ||
| OzoneObj.StoreType.OZONE, IAccessAuthorizer.ACLType.WRITE_ACL, | ||
| volume, null, null); | ||
|
Comment on lines
+67
to
+69
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems this is a regression, previously we don't always require WRITE_ACL, but not super.preExecute requires WRITE_ACL. Please check this and write a test for this in another ticket. |
||
| } catch (IOException ex) { | ||
| // Ensure audit log captures preExecute failures | ||
| Map<String, String> auditMap = new LinkedHashMap<>(); | ||
| auditMap.put(OzoneConsts.VOLUME, volume); | ||
| List<OzoneAcl> acls = getAcls(); | ||
| if (acls != null) { | ||
| auditMap.put(OzoneConsts.ACL, acls.toString()); | ||
| } | ||
| // Determine which action based on request type | ||
| OMAction action = OMAction.SET_ACL; | ||
| if (omRequest.hasAddAclRequest()) { | ||
| action = OMAction.ADD_ACL; | ||
| } else if (omRequest.hasRemoveAclRequest()) { | ||
| action = OMAction.REMOVE_ACL; | ||
| } | ||
| markForAudit(ozoneManager.getAuditLogger(), | ||
| buildAuditMessage(action, auditMap, ex, | ||
| omRequest.getUserInfo())); | ||
| throw ex; | ||
| } | ||
| } | ||
|
|
||
| return omRequest; | ||
| } | ||
|
|
||
| @Override | ||
| public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, ExecutionContext context) { | ||
| final long trxnLogIndex = context.getIndex(); | ||
|
|
@@ -71,12 +110,6 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut | |
| boolean lockAcquired = false; | ||
| Result result; | ||
| try { | ||
| // check Acl | ||
| if (ozoneManager.getAclsEnabled()) { | ||
| checkAcls(ozoneManager, OzoneObj.ResourceType.VOLUME, | ||
| OzoneObj.StoreType.OZONE, IAccessAuthorizer.ACLType.WRITE_ACL, | ||
| volume, null, null); | ||
| } | ||
| mergeOmLockDetails(omMetadataManager.getLock().acquireWriteLock( | ||
| VOLUME_LOCK, volume)); | ||
| lockAcquired = getOmLockDetails().isLockAcquired(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,14 +58,16 @@ public class OMVolumeAddAclRequest extends OMVolumeAclRequest { | |
|
|
||
| @Override | ||
| public OMRequest preExecute(OzoneManager ozoneManager) throws IOException { | ||
| // Call parent preExecute to perform ACL check | ||
| OMRequest omRequest = super.preExecute(ozoneManager); | ||
|
|
||
| long modificationTime = Time.now(); | ||
| OzoneManagerProtocolProtos.AddAclRequest.Builder addAclRequestBuilder = | ||
| getOmRequest().getAddAclRequest().toBuilder() | ||
| omRequest.getAddAclRequest().toBuilder() | ||
| .setModificationTime(modificationTime); | ||
|
Comment on lines
65
to
67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, we also might want to have |
||
|
|
||
| return getOmRequest().toBuilder() | ||
| return omRequest.toBuilder() | ||
| .setAddAclRequest(addAclRequestBuilder) | ||
| .setUserInfo(getUserInfo()) | ||
| .build(); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.