jtuglu1 commented on code in PR #19541:
URL: https://github.com/apache/druid/pull/19541#discussion_r3352912574
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java:
##########
@@ -165,29 +165,39 @@ public Response specPost(
.build();
}
- if (Boolean.TRUE.equals(skipRestartIfUnmodified) &&
!manager.shouldUpdateSupervisor(spec)) {
- return Response.ok(ImmutableMap.of("id", spec.getId(),
"restarted", false)).build();
- }
+ // Decide and apply atomically so the restart decision cannot go
stale under a concurrent POST.
+ final SupervisorManager.SpecUpdateOutcome outcome =
+ manager.createOrUpdateAndStartSupervisor(spec,
Boolean.TRUE.equals(skipRestartIfUnmodified));
- manager.createOrUpdateAndStartSupervisor(spec);
-
- final String auditPayload
- = StringUtils.format("Update supervisor[%s] for datasource[%s]",
spec.getId(), spec.getDataSources());
- auditManager.doAudit(
- AuditEntry.builder()
- .key(spec.getId())
- .type("supervisor")
- .auditInfo(AuthorizationUtils.buildAuditInfo(req))
-
.request(AuthorizationUtils.buildRequestInfo("overlord", req))
- .payload(auditPayload)
- .build()
- );
+ // Audit any path that mutated the persisted spec; a no-op UNCHANGED
submission is not audited.
+ if (outcome != SupervisorManager.SpecUpdateOutcome.UNCHANGED) {
+ auditSupervisorUpdate(spec, req);
+ }
- return Response.ok(ImmutableMap.of("id", spec.getId(), "restarted",
true)).build();
+ final boolean restarted = outcome ==
SupervisorManager.SpecUpdateOutcome.RESTARTED;
+ return Response.ok(ImmutableMap.of("id", spec.getId(), "restarted",
restarted)).build();
Review Comment:
+1 – this makes sense.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]