Skip to content

Audit workload management actions - #3

Draft
RyanL1997 wants to merge 1 commit into
mainfrom
audit/wlm-action-events
Draft

RyanL1997 wants to merge 1 commit into
mainfrom
audit/wlm-action-events

Conversation

@RyanL1997

Copy link
Copy Markdown
Owner

Description

  • Category: New feature
  • Workload management actions currently have no Security audit event. A search that a workload group refuses at admission, or cancels while it is running, leaves no audit trace at all — the only record is the one written when the request arrived, which is identical to that of a search that ran to completion. This draft consumes the node-local notifier proposed in Expose workload management action notifications OpenSearch#1 and adds WORKLOAD_MANAGEMENT_ACTION events.
  • Events are delivered through a bounded asynchronous queue, so no audit-sink work runs on the thread that rejected or cancelled. Queue overflow is counted and logged at power-of-two intervals. The category is in the default disabled list, and existing explicit category configuration continues to apply.

The two sources are not symmetric, and this is the main thing to review

Rejection Cancellation
Raised on the request's own thread, during admission the workload management scheduler, on GENERIC
Authenticated user available not available
Origin available not available
audit_request_id available, correlates with that request's other records not available
Resource attribution resource type, threshold, observed usage not available at the per-task callback
Task id none — no task exists yet at admission available

A rejection is therefore a well-correlated event: it joins the AUTHENTICATED record for the same request through audit_request_id, so the query text and index are recoverable from that record when request-body logging is enabled.

A cancellation is not. WorkloadGroupService cancels from threadPool.scheduleWithFixedDelay(..., ThreadPool.Names.GENERIC), so there is no request context to read — no user, no origin, no request id. The event carries the task id instead. Joining that back to the originating request needs audit_trace_task_id, which only appears when transport-layer auditing is enabled. Propagating bounded correlation context into the cancellation path is core work and is the obvious follow-up; it is deliberately not attempted here.

No audit-sink recursion guard, unlike the circuit breaker equivalent

cwperks#151 needs a self-suppression marker because a circuit breaker can trip on the audit sink's own index write. Workload management governs only SearchTask and SearchShardTask, so it can never act on an index write, and no marker is required. For the same reason this draft does not skip events with an unknown origin: for workload management, unknown origin is the cancellation path rather than a possible audit-sink write, and skipping it would discard exactly the events the feature exists for.

Example audit documents

A rejection, with caller and request id available:

{
  "audit_category": "WORKLOAD_MANAGEMENT_ACTION",
  "audit_request_effective_user": "alice",
  "audit_request_id": "6Zz0D6IB46_N3ehSzqW3",
  "audit_request_origin": "REST",
  "audit_wlm_action": "REJECTED",
  "audit_wlm_workload_group_id": "wg-analytics",
  "audit_wlm_resiliency_mode": "ENFORCED",
  "audit_wlm_resource_type": "CPU",
  "audit_wlm_resource_threshold": 0.8,
  "audit_wlm_resource_usage": 0.95
}

A cancellation, with no request context:

{
  "audit_category": "WORKLOAD_MANAGEMENT_ACTION",
  "audit_wlm_action": "CANCELLED",
  "audit_wlm_workload_group_id": "wg-analytics",
  "audit_wlm_task_id": 1042
}

The timestamp is when the asynchronous worker creates the message, not the exact moment of the action.

Draft limitations and follow-up

  • This PR requires Expose workload management action notifications OpenSearch#1 and a published OpenSearch snapshot containing it. CI against the existing snapshot will not compile until that dependency is available.
  • Cancellation events cannot currently be correlated to a request without transport-layer auditing. A core context-propagation change is needed before cancellation correlation can be claimed.
  • Events are best-effort: a full queue, a sink failure, or shutdown can drop them.
  • One category covers both actions. Splitting them would let an operator audit cancellations without rejections, which may matter if rejections are high-volume under load; not done here to keep the change small.
  • A new audit category must be coordinated with mixed-version nodes; public documentation and upgrade guidance still need to be written.
  • No integration test yet. The notifier contract is covered by unit tests on both sides; an end-to-end test needs a cluster that can be driven into a workload group breach.

Issues Resolved

None.

Testing

  • ./gradlew compileJava against a locally published core build containing the notifier — passed.
  • ./gradlew spotlessApply test --tests 'org.opensearch.security.auditlog.impl.WorkloadManagementAuditListenerTest' — passed.

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Add a WORKLOAD_MANAGEMENT_ACTION audit event, raised when a workload group
refuses a search at admission or cancels one while it is running. The events
are produced by consuming the node-local notifier added in core.

Delivery uses a bounded single-threaded queue so no audit-sink work runs on
the thread that rejected or cancelled. Overflow is counted and logged. The
category is disabled by default.

The two sources carry different context. A rejection is raised on the
request's own thread, so it has the authenticated user, the origin and the
request id, and correlates with that request's other audit records. A
cancellation is raised from the workload management scheduler on the generic
thread pool and has none of those; it carries the task id instead.

No audit-sink suppression marker is needed, because workload management
governs only search tasks and so cannot act on the audit sink's own index
writes. For the same reason events with an unknown origin are recorded
rather than skipped: for workload management that is the cancellation path.

Signed-off-by: Jialiang Liang <jiallian@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant