Skip to content

Commit 7b190a6

Browse files
rzo1claude
andcommitted
Cover the reference scan continuing past a candidate topology with no code blob
Review feedback on #9011: a KeyNotFoundException while collecting dependency references means the candidate topology contributes no references, unlike a read failure it does not abort the scan or trigger the conservative fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent fd84f48 commit 7b190a6

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

storm-server/src/test/java/org/apache/storm/daemon/nimbus/NimbusTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,29 @@ void doCleanupReclaimsOnlyProvablyUniqueDependencyBlobsWhenTheReferencesCannotBe
548548
verify(store).deleteBlob(eq(ConfigUtils.masterStormJarKey("dead-topo")), any());
549549
}
550550

551+
@Test
552+
void doCleanupContinuesTheReferenceScanWhenACandidateTopologyHasNoCodeBlob() throws Exception {
553+
BlobStore store = mock(BlobStore.class);
554+
IStormClusterState state = mock(IStormClusterState.class);
555+
when(store.storedTopoIds()).thenReturn(Set.of("dead-topo", "live-topo", "gone-topo"));
556+
when(state.activeStorms()).thenReturn(List.of("live-topo", "gone-topo"));
557+
storeTopology(store, "dead-topo", List.of(UNIQUE_JAR_KEY),
558+
List.of(LEGACY_ARTIFACT_KEY, "dep-other-artifact-2.0.0.jar"));
559+
storeTopology(store, "live-topo", List.of(), List.of(LEGACY_ARTIFACT_KEY));
560+
// one candidate topology has no code blob at all, so it references no dependencies; unlike a read
561+
// failure this does not abort the scan, the remaining topologies' references are still collected
562+
when(store.readBlob(eq(ConfigUtils.masterStormCodeKey("gone-topo")), any()))
563+
.thenThrow(new KeyNotFoundException(ConfigUtils.masterStormCodeKey("gone-topo")));
564+
565+
cleanupNimbus(store, state).doCleanup();
566+
567+
// the scan succeeded, so even a shareable-shaped key is reclaimed once nothing references it
568+
verify(store).deleteBlob(eq("dep-other-artifact-2.0.0.jar"), any());
569+
verify(store).deleteBlob(eq(UNIQUE_JAR_KEY), any());
570+
// while the reference of the topology that could be read is honoured
571+
verify(store, never()).deleteBlob(eq(LEGACY_ARTIFACT_KEY), any());
572+
}
573+
551574
@Test
552575
void everyDependencyKeyACurrentClientGeneratesIsRecognisedAsUniqueToOneTopology() {
553576
for (String fileName : List.of("commons-lang3-3.12.0.jar", "some.lib.tar.gz", "noextension")) {

0 commit comments

Comments
 (0)