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

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


The following commit(s) were added to refs/heads/master by this push:
     new f481ddc4cd Reject enabling debug on topologies without event loggers 
(#9285)
f481ddc4cd is described below

commit f481ddc4cd2f232f831ec010ca24ea488a75fc2f
Author: 龙骑士k <[email protected]>
AuthorDate: Mon Nov 23 18:34:01 2026 +0000

    Reject enabling debug on topologies without event loggers (#9285)
    
    * Reject enabling debug on topologies without event loggers
    
    Closes issue 7588
    
    ## What is the purpose of the change
    
    Nimbus now rejects a request to enable debug when the topology has no event 
loggers, and stores no debug options for it. The UI already disables the Debug 
button when topology.eventlogger.executors is 0, but the UI REST endpoint and 
Thrift clients could still enable debug. The check is in Nimbus.debug() because 
the UI REST endpoint and Thrift clients all go through it, so one check covers 
every entry point. It uses the existing StormCommon.hasEventLoggers() on the 
merged topology conf [...]
    
    ## How was the change tested
    
    NimbusClojurePortTest.testDebugRejectedWithoutEventLoggers submits a 
topology with topology.eventlogger.executors set to 0 on a simulated time 
LocalCluster. It checks that enabling debug at topology and at component level 
throws InvalidTopologyException, that no debug options are stored, and that 
disabling debug still succeeds. The test fails without the Nimbus change. 
NimbusClojurePortTest.testDebugAllowedWithNullEventLoggers submits with 
topology.eventlogger.executors set to null, c [...]
    
    ## Upgrade notes
    
    Enabling debug on a topology whose topology.eventlogger.executors is 0 now 
fails instead of succeeding with no events logged. The UI REST endpoint returns 
HTTP 500 and Thrift clients get a TApplicationException. Set 
topology.eventlogger.executors to a value greater than 0 to use debug.
    
    ## AI Disclosure
    
    Human-led contribution. Grok Bot, working for dragonknightk, assisted with 
this change, including the code, tests, and description. All submitted content 
was reviewed by a human before submission.
    
    Signed-off-by: dragonknightk 
<[email protected]>
    
    * Mention the null event logger option and assert rejected debug keys
    
    Closes issue 7588
    
    ## What is the purpose of the change
    
    Nimbus now rejects a request to enable debug when the topology has no event 
loggers, and stores no debug options for it. The UI already disables the Debug 
button when topology.eventlogger.executors is 0, but the UI REST endpoint and 
Thrift clients could still enable debug. The check is in Nimbus.debug() because 
the UI REST endpoint and Thrift clients all go through it, so one check covers 
every entry point. It uses the existing StormCommon.hasEventLoggers() on the 
merged topology conf [...]
    
    ## How was the change tested
    
    NimbusClojurePortTest.testDebugRejectedWithoutEventLoggers submits a 
topology with topology.eventlogger.executors set to 0 on a simulated time 
LocalCluster. It checks that enabling debug at topology and at component level 
throws InvalidTopologyException, that component_debug contains neither the 
topology id nor the "spout" key, and that disabling debug still succeeds. The 
test fails without the Nimbus change. 
NimbusClojurePortTest.testDebugAllowedWithNullEventLoggers submits with topo 
[...]
    
    ## Upgrade notes
    
    Enabling debug on a topology whose topology.eventlogger.executors is 0 now 
fails instead of succeeding with no events logged. The UI REST endpoint returns 
HTTP 500 and Thrift clients get a TApplicationException. Set 
topology.eventlogger.executors to a value greater than 0, or unset it (null) 
for one event logger per worker.
    
    ## AI Disclosure
    
    Human-led contribution. Grok Bot, working for dragonknightk, assisted with 
this change, including the code, tests, and description. All submitted content 
was reviewed by a human before submission.
    
    Signed-off-by: dragonknightk 
<[email protected]>
    
    ---------
    
    Signed-off-by: dragonknightk 
<[email protected]>
---
 .../org/apache/storm/daemon/nimbus/Nimbus.java     |  6 ++
 .../storm/daemon/nimbus/NimbusClojurePortTest.java | 77 +++++++++++++++++++++-
 2 files changed, 81 insertions(+), 2 deletions(-)

diff --git 
a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java 
b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
index eab1fe49e4..bf97a8d924 100644
--- a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
+++ b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
@@ -3987,6 +3987,12 @@ public class Nimbus implements Iface, Shutdownable, 
DaemonCommon {
             if (topoId == null) {
                 throw new WrappedNotAliveException(topoName);
             }
+            if (enable && !StormCommon.hasEventLoggers(topoConf)) {
+                throw new WrappedInvalidTopologyException("Cannot enable debug 
for topology '"
+                    + topoName + "' because it has no event loggers. Set "
+                    + Config.TOPOLOGY_EVENTLOGGER_EXECUTORS + " to a value 
greater than 0, "
+                    + "or unset it (null) for one event logger per worker.");
+            }
 
             DebugOptions options = new DebugOptions();
             options.set_enable(enable);
diff --git 
a/storm-server/src/test/java/org/apache/storm/daemon/nimbus/NimbusClojurePortTest.java
 
b/storm-server/src/test/java/org/apache/storm/daemon/nimbus/NimbusClojurePortTest.java
index 33a59d11e7..05f2363145 100644
--- 
a/storm-server/src/test/java/org/apache/storm/daemon/nimbus/NimbusClojurePortTest.java
+++ 
b/storm-server/src/test/java/org/apache/storm/daemon/nimbus/NimbusClojurePortTest.java
@@ -273,7 +273,8 @@ public class NimbusClojurePortTest {
             StormTopology topology = Thrift.buildTopology(
                 Map.of("spout", Thrift.prepareSpoutDetails(new 
TestPlannerSpout(true), 3)),
                 Map.of());
-            cluster.submitTopology("t1", Map.of(Config.TOPOLOGY_WORKERS, 1), 
topology);
+            cluster.submitTopology("t1", Map.of(Config.TOPOLOGY_WORKERS, 1,
+                Config.TOPOLOGY_EVENTLOGGER_EXECUTORS, 1), topology);
             nimbus.debug("t1", "spout", true, 100);
         }
     }
@@ -285,11 +286,83 @@ public class NimbusClojurePortTest {
             StormTopology topology = Thrift.buildTopology(
                 Map.of("spout", Thrift.prepareSpoutDetails(new 
TestPlannerSpout(true), 3)),
                 Map.of());
-            cluster.submitTopology("t1", Map.of(Config.TOPOLOGY_WORKERS, 1), 
topology);
+            cluster.submitTopology("t1", Map.of(Config.TOPOLOGY_WORKERS, 1,
+                Config.TOPOLOGY_EVENTLOGGER_EXECUTORS, 1), topology);
             nimbus.debug("t1", "", true, 100);
         }
     }
 
+    @Test
+    public void testDebugRejectedWithoutEventLoggers() throws Exception {
+        // Expected behavior from docs/Eventlogging.md ("Event logging needs 
to be enabled
+        // first by setting the storm config topology.eventlogger.executors to 
a non zero value")
+        // and issue 7588: a direct debug request must not enable debug when 
the topology has
+        // no event loggers.
+        try (LocalCluster cluster = new LocalCluster.Builder()
+                .withSimulatedTime()
+                .withDaemonConf(Map.of(
+                    DaemonConfig.SUPERVISOR_ENABLE, false,
+                    Config.TOPOLOGY_ACKER_EXECUTORS, 0))
+                .build()) {
+            Nimbus nimbus = cluster.getNimbus();
+            StormTopology topology = Thrift.buildTopology(
+                Map.of("spout", Thrift.prepareSpoutDetails(new 
TestPlannerSpout(true), 3)),
+                Map.of());
+            cluster.submitTopology("t1", Map.of(Config.TOPOLOGY_WORKERS, 1,
+                Config.TOPOLOGY_EVENTLOGGER_EXECUTORS, 0), topology);
+            String topoId = cluster.getClusterState().getTopoId("t1").get();
+
+            assertThrows(InvalidTopologyException.class,
+                () -> nimbus.debug("t1", "", true, 100));
+            assertThrows(InvalidTopologyException.class,
+                () -> nimbus.debug("t1", "spout", true, 100));
+            StormBase base = cluster.getClusterState().stormBase(topoId, null);
+            assertFalse(base.is_set_component_debug()
+                && (base.get_component_debug().containsKey(topoId)
+                    || base.get_component_debug().containsKey("spout")),
+                "Rejected debug requests must not store debug options");
+
+            // Disabling debug stays allowed
+            nimbus.debug("t1", "", false, 0);
+        }
+    }
+
+    @Test
+    public void testDebugAllowedWithNullEventLoggers() throws Exception {
+        // Expected behavior from docs/Eventlogging.md: 
"topology.eventlogger.executors": nil means
+        // "One event logger task per worker.", so the topology has event 
loggers and debug can be
+        // enabled.
+        try (LocalCluster cluster = new LocalCluster.Builder()
+                .withSimulatedTime()
+                .withDaemonConf(Map.of(
+                    DaemonConfig.SUPERVISOR_ENABLE, false,
+                    Config.TOPOLOGY_ACKER_EXECUTORS, 0))
+                .build()) {
+            Nimbus nimbus = cluster.getNimbus();
+            StormTopology topology = Thrift.buildTopology(
+                Map.of("spout", Thrift.prepareSpoutDetails(new 
TestPlannerSpout(true), 3)),
+                Map.of());
+            Map<String, Object> submitConf = new HashMap<>();
+            submitConf.put(Config.TOPOLOGY_WORKERS, 1);
+            submitConf.put(Config.TOPOLOGY_EVENTLOGGER_EXECUTORS, null);
+            cluster.submitTopology("t1", submitConf, topology);
+            String topoId = cluster.getClusterState().getTopoId("t1").get();
+
+            // defaults.yaml sets 0, so check that the conf debug() merges 
really holds null
+            Map<String, Object> nimbusConf = fromJson(nimbus.getNimbusConf());
+            assertEquals(0,
+                ((Number) 
nimbusConf.get(Config.TOPOLOGY_EVENTLOGGER_EXECUTORS)).intValue());
+            Map<String, Object> mergedConf =
+                Utils.merge(nimbusConf, 
fromJson(nimbus.getTopologyConf(topoId)));
+            
assertTrue(mergedConf.containsKey(Config.TOPOLOGY_EVENTLOGGER_EXECUTORS));
+            assertNull(mergedConf.get(Config.TOPOLOGY_EVENTLOGGER_EXECUTORS));
+
+            nimbus.debug("t1", "", true, 100);
+            StormBase base = cluster.getClusterState().stormBase(topoId, null);
+            assertTrue(base.get_component_debug().get(topoId).is_enable());
+        }
+    }
+
     @Test
     public void emptySaveConfigResultsInAllUnchangedActions() throws Exception 
{
         IStormClusterState clusterState = 
Mockito.mock(IStormClusterState.class);

Reply via email to