This is an automated email from the ASF dual-hosted git repository.

abhishekrb19 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new a090448fe01 feat: add `restarted` field to supervisor update API 
response (#19349)
a090448fe01 is described below

commit a090448fe01544549c357e43c7d81d88baffeb32
Author: Abhishek Radhakrishnan <[email protected]>
AuthorDate: Mon Apr 20 10:14:31 2026 -0700

    feat: add `restarted` field to supervisor update API response (#19349)
    
    Adds a restarted boolean field to the supervisor POST endpoint response to 
indicate whether the supervisor was actually restarted when 
skipRestartIfUnmodified is set to true.
    
    When using the skipRestartIfUnmodified parameter, callers had no way to 
determine from the response whether the supervisor was actually restarted or 
skipped. This should provide feedback to API callers about the supervisor 
restart status.
---
 docs/api-reference/supervisor-api.md                             | 7 ++++++-
 .../docker/IngestionBackwardCompatibilityDockerTest.java         | 9 +++++++++
 .../druid/testing/embedded/indexing/IngestionSmokeTest.java      | 7 ++++++-
 .../druid/indexing/overlord/supervisor/SupervisorResource.java   | 4 ++--
 .../indexing/overlord/supervisor/SupervisorResourceTest.java     | 8 ++++----
 .../org/apache/druid/rpc/indexing/OverlordClientImplTest.java    | 4 ++--
 6 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/docs/api-reference/supervisor-api.md 
b/docs/api-reference/supervisor-api.md
index 2f0d72deda1..d321af14302 100644
--- a/docs/api-reference/supervisor-api.md
+++ b/docs/api-reference/supervisor-api.md
@@ -2508,11 +2508,16 @@ curl 
"http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/supervisor?skipRestartIfUnmo
 
   ```json
 {
-    "id": "social_media"
+    "id": "social_media",
+    "restarted": true
 }
   ```
 </details>
 
+The response includes the following fields:
+- `id`: The supervisor ID.
+- `restarted`: A boolean indicating whether the supervisor was restarted. When 
`skipRestartIfUnmodified` is set to `true` and the supervisor spec is 
unchanged, this field will be `false`; otherwise, it will be `true`.
+
 ### Suspend a running supervisor
 
 Suspends a single running supervisor. Returns the updated supervisor spec, 
where the `suspended` property is set to `true`. The suspended supervisor 
continues to emit logs and metrics.
diff --git 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/docker/IngestionBackwardCompatibilityDockerTest.java
 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/docker/IngestionBackwardCompatibilityDockerTest.java
index 45b2ee7d2ed..ad3855efacd 100644
--- 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/docker/IngestionBackwardCompatibilityDockerTest.java
+++ 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/docker/IngestionBackwardCompatibilityDockerTest.java
@@ -37,6 +37,8 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 
+import java.util.Map;
+
 /**
  * Runs some basic ingestion tests using Coordinator and Overlord at version
  * {@link DruidContainer.Image#APACHE_31} and other services at current version
@@ -111,6 +113,13 @@ public class IngestionBackwardCompatibilityDockerTest 
extends IngestionSmokeTest
     }
   }
 
+  @Override
+  protected void validateSupervisorUpdateResponse(Map<String, String> 
startSupervisorResult, String supervisorId)
+  {
+    // Older Overlord versions did not include "restarted" in the API response.
+    Assertions.assertEquals(Map.of("id", supervisorId), startSupervisorResult);
+  }
+
   @Override
   protected void waitForNextCoordinatorCacheSync()
   {
diff --git 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/IngestionSmokeTest.java
 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/IngestionSmokeTest.java
index 1e9ec375ce9..a6ed50dd7f0 100644
--- 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/IngestionSmokeTest.java
+++ 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/IngestionSmokeTest.java
@@ -297,7 +297,7 @@ public class IngestionSmokeTest extends 
EmbeddedClusterTestBase
     final Map<String, String> startSupervisorResult = 
cluster.callApi().onLeaderOverlord(
         o -> o.postSupervisor(kafkaSupervisorSpec)
     );
-    Assertions.assertEquals(Map.of("id", supervisorId), startSupervisorResult);
+    validateSupervisorUpdateResponse(startSupervisorResult, supervisorId);
 
     waitForSegmentsToBeQueryable(1);
 
@@ -417,6 +417,11 @@ public class IngestionSmokeTest extends 
EmbeddedClusterTestBase
     );
   }
 
+  protected void validateSupervisorUpdateResponse(Map<String, String> 
startSupervisorResult, String supervisorId)
+  {
+    Assertions.assertEquals(Map.of("id", supervisorId, "restarted", "true"), 
startSupervisorResult);
+  }
+
   protected void waitForNextCoordinatorCacheSync()
   {
     eventCollector.latchableEmitter().waitForNextEvent(
diff --git 
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
 
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
index 78aa16b37cb..fc1767a3594 100644
--- 
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
+++ 
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
@@ -166,7 +166,7 @@ public class SupervisorResource
           }
 
           if (Boolean.TRUE.equals(skipRestartIfUnmodified) && 
!manager.shouldUpdateSupervisor(spec)) {
-            return Response.ok(ImmutableMap.of("id", spec.getId())).build();
+            return Response.ok(ImmutableMap.of("id", spec.getId(), 
"restarted", false)).build();
           }
 
           manager.createOrUpdateAndStartSupervisor(spec);
@@ -183,7 +183,7 @@ public class SupervisorResource
                         .build()
           );
 
-          return Response.ok(ImmutableMap.of("id", spec.getId())).build();
+          return Response.ok(ImmutableMap.of("id", spec.getId(), "restarted", 
true)).build();
         }
     );
   }
diff --git 
a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResourceTest.java
 
b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResourceTest.java
index 9282e49d19b..268f6432a1d 100644
--- 
a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResourceTest.java
+++ 
b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResourceTest.java
@@ -178,7 +178,7 @@ public class SupervisorResourceTest extends EasyMockSupport
     verifyAll();
 
     Assert.assertEquals(200, response.getStatus());
-    Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
+    Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", true), 
response.getEntity());
     resetAll();
 
     
EasyMock.expect(taskMaster.getSupervisorManager()).andReturn(Optional.absent());
@@ -248,7 +248,7 @@ public class SupervisorResourceTest extends EasyMockSupport
     verifyAll();
 
     Assert.assertEquals(200, response.getStatus());
-    Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
+    Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", false), 
response.getEntity());
 
     resetAll();
 
@@ -269,7 +269,7 @@ public class SupervisorResourceTest extends EasyMockSupport
     verifyAll();
 
     Assert.assertEquals(200, response.getStatus());
-    Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
+    Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", true), 
response.getEntity());
   }
 
   @Test
@@ -300,7 +300,7 @@ public class SupervisorResourceTest extends EasyMockSupport
     verifyAll();
 
     Assert.assertEquals(200, response.getStatus());
-    Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
+    Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", true), 
response.getEntity());
     resetAll();
 
     
EasyMock.expect(taskMaster.getSupervisorManager()).andReturn(Optional.absent());
diff --git 
a/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
 
b/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
index 2a1af270aba..290f69d693e 100644
--- 
a/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
+++ 
b/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
@@ -283,11 +283,11 @@ public class OverlordClientImplTest
             .jsonContent(jsonMapper, supervisorSpec),
         HttpResponseStatus.OK,
         ImmutableMap.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON),
-        jsonMapper.writeValueAsBytes(Map.of("id", supervisorId))
+        jsonMapper.writeValueAsBytes(Map.of("id", supervisorId, "restarted", 
true))
     );
 
     Assert.assertEquals(
-        Map.of("id", supervisorId),
+        Map.of("id", supervisorId, "restarted", "true"),
         overlordClient.postSupervisor(supervisorSpec).get()
     );
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to