diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java index 6fce895185f7..33b905c9d9c3 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java @@ -42,6 +42,7 @@ import org.apache.hadoop.hdds.scm.ScmConfigKeys; import org.apache.hadoop.hdds.scm.container.ContainerID; import org.apache.hadoop.hdds.scm.events.SCMEvents; +import org.apache.hadoop.hdds.scm.exceptions.SCMException; import org.apache.hadoop.hdds.scm.node.NodeManager; import org.apache.hadoop.hdds.scm.safemode.SCMSafeModeManager.SafeModeStatus; import org.apache.hadoop.hdds.server.events.EventPublisher; @@ -56,6 +57,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes.FAILED_TO_FIND_SUITABLE_NODE; + /** * Implements api needed for management of pipelines. All the write operations * for pipelines must come via PipelineManager. It synchronises all write @@ -272,8 +275,15 @@ public Pipeline createPipeline(ReplicationType type, recordMetricsForPipeline(pipeline); return pipeline; } catch (IOException ex) { - LOG.error("Failed to create pipeline of type {} and factor {}. " + - "Exception: {}", type, factor, ex.getMessage()); + if (ex instanceof SCMException && + ((SCMException) ex).getResult() == FAILED_TO_FIND_SUITABLE_NODE) { + // Avoid spam SCM log with errors when SCM has enough open pipelines + LOG.debug("Can't create more pipelines of type {} and factor {}. " + + "Reason: {}", type, factor, ex.getMessage()); + } else { + LOG.error("Failed to create pipeline of type {} and factor {}. " + + "Exception: {}", type, factor, ex.getMessage()); + } metrics.incNumPipelineCreationFailed(); throw ex; } finally { diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestSCMPipelineManager.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestSCMPipelineManager.java index 62289b95a9a3..25957d8d28d1 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestSCMPipelineManager.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestSCMPipelineManager.java @@ -76,6 +76,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.slf4j.event.Level.INFO; /** * Test cases to verify PipelineManager. @@ -304,6 +305,8 @@ public void testPipelineCreationFailedMetric() throws Exception { "NumPipelineCreationFailed", metrics); Assert.assertEquals(0, numPipelineCreateFailed); + LogCapturer logs = LogCapturer.captureLogs(SCMPipelineManager.getLog()); + GenericTestUtils.setLogLevel(SCMPipelineManager.getLog(), INFO); //This should fail... try { pipelineManager.createPipeline(HddsProtos.ReplicationType.RATIS, @@ -313,6 +316,10 @@ public void testPipelineCreationFailedMetric() throws Exception { // pipeline creation failed this time. Assert.assertEquals(SCMException.ResultCodes.FAILED_TO_FIND_SUITABLE_NODE, ioe.getResult()); + Assert.assertFalse(logs.getOutput().contains( + "Failed to create pipeline of type")); + } finally { + logs.stopCapturing(); } metrics = getMetrics(