RANGER-5719: Shared partition-plan library and SPIFFE header auth utilities - #1137
RANGER-5719: Shared partition-plan library and SPIFFE header auth utilities#1137ramackri wants to merge 5 commits into
Conversation
Wire PluginHeaderAuthConfig into RangerAuditServerDestination so plugins send X-Spiffe-Id on audit POSTs when xasecure.audit.destination.auditserver.authn.header.enabled=true. Requires RANGER-5719 (apache#1137) for PluginHeaderAuthConfig and setTrustedAuthHeaders().
…uting Add agents-common partition plan model, allocator, validator, routing helpers, and PolicyDownloadAuthUsersUtil for RANGER-5655. SPIFFE header utilities move to RANGER-5723 (apache#1139).
c4cf544 to
0ced753
Compare
Drop scalePlugin, replacePlan, isPromoteAlreadyApplied, sameContentAs, toAllowedUserSets, hashToSlotIndex, and related helpers that no production caller uses in the 5721/5722 design; can reintroduce when scaling or bulk replace is wired.
Remove PluginEntry.empty(), the four-arg promotePlugin overload, and DEFAULT_AUDIT_TOPIC (tests use the literal topic name).
No callers in apache#1137, rangerRelease 5721/5722, or tests; plans are built via plugins(map).
There was a problem hiding this comment.
Pull request overview
Introduces a shared “audit partition plan” library under agents-common to model, validate, allocate, and route Admin-managed Kafka audit partitions, with accompanying unit tests to lock down expected behaviors and JSON compatibility.
Changes:
- Added canonical JSON model types for the partition plan (
PartitionPlan,PluginEntry,BufferEntry) plus JSON round-trip support. - Added core utilities for plan lifecycle and runtime use: allocation/mutation (
PartitionPlanAllocator), validation (PartitionPlanValidator), and routing helpers (PartitionPlanRoutingUtils). - Added supporting utilities/constants (
AuditPartitionPlanConstants,AuditPartitionPlanAdminConfig,PolicyDownloadAuthUsersUtil) and a focused unit test suite.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| agents-common/src/main/java/org/apache/ranger/audit/partition/AuditPartitionPlanAdminConfig.java | Reads Admin configuration to determine per-plugin partition allocation defaults/overrides. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/AuditPartitionPlanConstants.java | Defines shared constants for the partition plan feature (defaults + property keys). |
| agents-common/src/main/java/org/apache/ranger/audit/partition/PartitionPlanAllocator.java | Implements append-only mutation helpers for promoting plugins/onboarding services/updating allow-lists. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/PartitionPlanRoutingUtils.java | Converts logical plan partition IDs to Kafka producer partition indices (0-based) with clamping. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/PartitionPlanValidator.java | Validates plan structure and enforces append-only constraints across updates. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/PolicyDownloadAuthUsersUtil.java | Parses/normalizes policy.download.auth.users values used for ingestor authorization metadata. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/exception/PartitionPlanException.java | Defines a dedicated runtime exception type for plan validation/allocation failures. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/model/BufferEntry.java | Models buffer partitions portion of the plan for future plugin promotions. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/model/PartitionPlan.java | Core JSON model + (de)serialization entrypoints and builder. |
| agents-common/src/main/java/org/apache/ranger/audit/partition/model/PluginEntry.java | Models per-plugin partitions and associated Ranger service repos. |
| agents-common/src/test/java/org/apache/ranger/audit/partition/AuditPartitionPlanAdminConfigTest.java | Verifies default/override resolution behavior for Admin config. |
| agents-common/src/test/java/org/apache/ranger/audit/partition/PartitionPlanAllocatorTest.java | Exercises allocator mutations (promotion/onboarding/removal/allow-list updates). |
| agents-common/src/test/java/org/apache/ranger/audit/partition/PartitionPlanRoutingUtilsTest.java | Verifies logical-id → Kafka-index mapping and clamping behavior. |
| agents-common/src/test/java/org/apache/ranger/audit/partition/PartitionPlanTestSupport.java | Provides reusable seed/pre-assigned plan fixtures for tests. |
| agents-common/src/test/java/org/apache/ranger/audit/partition/PartitionPlanValidatorTest.java | Covers validator rejection/acceptance scenarios and append-only constraints. |
| agents-common/src/test/java/org/apache/ranger/audit/partition/PolicyDownloadAuthUsersUtilTest.java | Verifies parsing/normalization rules for allow-list values. |
| agents-common/src/test/java/org/apache/ranger/audit/partition/model/PartitionPlanJsonTest.java | Validates JSON round-trip stability for seed/onboarded/allow-list variants. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Reject null plugin entries, non-contiguous partition ids, and ineffective allow-lists - Split append-only validation messages; allow metadata updates at same partition count - Simplify tail partition allocation; harden allow-list normalization against null elements
|
|
||
| /** Parses {@code policy.download.auth.users} service config for audit ingestor authorization. */ | ||
| public final class PolicyDownloadAuthUsersUtil { | ||
| public static final String CONFIG_NAME = "policy.download.auth.users"; |
There was a problem hiding this comment.
Do we need to rely only on "policy.download.auth.users"? I feel we should have a new param "service.access.audit.user" which will be a keytab user (by default service user can be there e.g hive, rangeraz, hdfs, etc) and if its not there then check for Service admin and if no there then look for "policy.download.auth.users". What do you say? @mneethiraj need your input on this. Thanks.
There was a problem hiding this comment.
@ramackri - if this is to determine the users authorized to report audits for a service, we should only recognize service.admin.users and service.admin.groups. Picking up users frompolicy.download.auth.users is not correct.
Summary
First PR in the RANGER-5655 series — Admin-managed Kafka audit partition plan.
JIRA: RANGER-5719
Split from closed #1135.
This PR adds the partition plan library only (17 files). It does not change runtime behavior, SPIFFE auth, Admin REST, ingestor, or DB schema. Safe to merge independently.
Outbound SPIFFE / trusted-header auth for the audit-server destination is in #1139 (RANGER-5723).
Partition plan library (
agents-common)Canonical JSON model stored in Admin
x_ranger_global_state(RangerAuditPartitionPlan):PartitionPlan,PluginEntry,BufferEntryPartitionPlanAllocatorPartitionPlanValidatorPartitionPlanRoutingUtilsPolicyDownloadAuthUsersUtilpolicy.download.auth.usersper service for ingestor allow-listsAuditPartitionPlanAdminConfigpartitions.per.plugin, per-plugin overrides)AuditPartitionPlanConstantsranger_auditstopic, initial version, property names)Tests: allocator, validator, routing, JSON round-trip, allow-list extraction.
Related PRs — RANGER-5655 merge order
AuditPartitionPlanMgrAuditPluginIdResolverdeferred to RANGER-5721.Test plan
mvn -pl agents-common -am test— partition plan unit tests passbuild-17,plugins-docker-build,services-docker-build(commitb0a5a1f67)Review follow-up
Addressed @rameeshm's Aug 14 comments in
b0a5a1f67:1..topicPartitionCountpartition ID validationappendTailPartitionsPolicyDownloadAuthUsersUtilsubList