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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2eb5805b6c HDDS-7738. SCM terminates when adding container to a closed 
pipeline (#4154)
2eb5805b6c is described below

commit 2eb5805b6c1f890cd86a50356a13eeb5018e3ead
Author: Duong Nguyen <[email protected]>
AuthorDate: Sat Jan 7 02:34:35 2023 -0800

    HDDS-7738. SCM terminates when adding container to a closed pipeline (#4154)
---
 .../hadoop/hdds/scm/pipeline/PipelineStateMap.java |  6 ++---
 .../hdds/scm/pipeline/TestPipelineManagerImpl.java | 26 +++++++++++++++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
index 6b40f28fc0..5db887b674 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
@@ -106,9 +106,9 @@ class PipelineStateMap {
 
     Pipeline pipeline = getPipeline(pipelineID);
     if (pipeline.isClosed()) {
-      throw new IOException(String
-          .format("Cannot add container to pipeline=%s in closed state",
-              pipelineID));
+      LOG.warn("Adding container {} to pipeline={} in CLOSED state." +
+          " This happens only for some exceptional cases." +
+          " Check for the previous exceptions.", containerID, pipelineID);
     }
     pipeline2container.get(pipelineID).add(containerID);
   }
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
index 1ed9b845ac..c75cb937e5 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
@@ -762,7 +762,7 @@ public class TestPipelineManagerImpl {
   }
 
   @Test
-  public void testAddContainerWithClosedPipeline() throws Exception {
+  public void testAddContainerWithClosedPipelineScmStart() throws Exception {
     GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.
             captureLogs(LoggerFactory.getLogger(PipelineStateMap.class));
     SCMHADBTransactionBuffer buffer = new 
SCMHADBTransactionBufferStub(dbStore);
@@ -786,6 +786,30 @@ public class TestPipelineManagerImpl {
             pipelineID + " in closed state"));
   }
 
+  @Test
+  public void testAddContainerWithClosedPipeline() throws Exception {
+    GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.
+        captureLogs(LoggerFactory.getLogger(PipelineStateMap.class));
+    SCMHADBTransactionBuffer buffer = new 
SCMHADBTransactionBufferStub(dbStore);
+    PipelineManagerImpl pipelineManager =
+        createPipelineManager(true, buffer);
+    Table<PipelineID, Pipeline> pipelineStore =
+        SCMDBDefinition.PIPELINES.getTable(dbStore);
+    Pipeline pipeline = pipelineManager.createPipeline(
+        RatisReplicationConfig
+            .getInstance(HddsProtos.ReplicationFactor.THREE));
+    PipelineID pipelineID = pipeline.getId();
+    pipelineManager.addContainerToPipeline(pipelineID, ContainerID.valueOf(1));
+    pipelineManager.getStateManager().updatePipelineState(
+        pipelineID.getProtobuf(), HddsProtos.PipelineState.PIPELINE_CLOSED);
+    buffer.flush();
+    Assertions.assertTrue(pipelineStore.get(pipelineID).isClosed());
+    pipelineManager.addContainerToPipeline(pipelineID,
+        ContainerID.valueOf(2));
+    assertTrue(logCapturer.getOutput().contains(
+        "Adding container #2 to pipeline=" + pipelineID + " in CLOSED 
state."));
+  }
+
   @Test
   public void testPipelineCloseFlow() throws IOException, TimeoutException {
     GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer


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

Reply via email to