You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2017/10/28 00:26:48 UTC

aurora git commit: Suppress multiline logging from mesos callbacks

Repository: aurora
Updated Branches:
  refs/heads/master f6c40a279 -> fb64e3a9f


Suppress multiline logging from mesos callbacks

Reviewed at https://reviews.apache.org/r/63383/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/fb64e3a9
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/fb64e3a9
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/fb64e3a9

Branch: refs/heads/master
Commit: fb64e3a9ffac224fc008298a30b6f1213edce525
Parents: f6c40a2
Author: Bill Farner <wf...@apache.org>
Authored: Fri Oct 27 17:26:34 2017 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Fri Oct 27 17:26:34 2017 -0700

----------------------------------------------------------------------
 .../scheduler/mesos/MesosCallbackHandler.java   | 12 ++++++---
 .../mesos/MesosCallbackHandlerTest.java         | 28 ++++++++++++++++++--
 2 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/fb64e3a9/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
index e93c4fa..fd5874d 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
@@ -298,7 +298,11 @@ public interface MesosCallbackHandler {
         message.append(" with ").append(status.getReason());
       }
       if (status.hasMessage()) {
-        message.append(": ").append(status.getMessage());
+        String[] lines = status.getMessage().split("\n");
+        message.append(": ").append(lines[0]);
+        if (lines.length > 1) {
+          message.append(" (truncated)");
+        }
       }
       if (debugLevel) {
         logger.debug(message.toString());
@@ -335,7 +339,7 @@ public interface MesosCallbackHandler {
 
     @Override
     public void handleLostAgent(AgentID agentId) {
-      log.info("Received notification of lost agent: " + agentId);
+      log.info("Received notification of lost agent: " + agentId.getValue());
       slavesLost.incrementAndGet();
     }
 
@@ -344,7 +348,9 @@ public interface MesosCallbackHandler {
       // With the current implementation of MESOS-313, Mesos is also reporting clean terminations of
       // custom executors via the executorLost callback.
       if (status != 0) {
-        log.warn("Lost executor " + executorID + " on slave " + slaveID + " with status " + status);
+        log.warn("Lost executor " + executorID.getValue()
+            + " on slave " + slaveID.getValue()
+            + " with status " + status);
         executorsLost.incrementAndGet();
       }
     }

http://git-wip-us.apache.org/repos/asf/aurora/blob/fb64e3a9/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java b/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
index 51d0371..8f8b86d 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
@@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.aurora.gen.MaintenanceMode.DRAINING;
 import static org.apache.aurora.gen.MaintenanceMode.NONE;
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
@@ -217,7 +218,6 @@ public class MesosCallbackHandlerTest extends EasyMockTest {
     storageUtil.expectOperations();
 
     storageUtil.schedulerStore.saveFrameworkId(FRAMEWORK_ID);
-    expectLastCall();
 
     registeredEventSink.post(new PubsubEvent.DriverRegistered());
 
@@ -465,7 +465,6 @@ public class MesosCallbackHandlerTest extends EasyMockTest {
         + "SOURCE_AGENT with REASON_RECONCILIATION: message";
 
     injectedLog.debug(expectedMsg);
-    expectLastCall().once();
 
     eventSink.post(new PubsubEvent.TaskStatusReceived(
         STATUS_RECONCILIATION.getState(),
@@ -483,6 +482,31 @@ public class MesosCallbackHandlerTest extends EasyMockTest {
   }
 
   @Test
+  public void testNoMultilineLogging() {
+    createHandler(true);
+
+    injectedLog.info("Received status update for task task-id in state "
+        + "TASK_RUNNING from SOURCE_AGENT: A (truncated)");
+    injectedLog.info("Received status update for task task-id in state "
+        + "TASK_RUNNING from SOURCE_AGENT: A string with one line");
+    eventSink.post(anyObject());
+    expectLastCall().anyTimes();
+    statusHandler.statusUpdate(anyObject());
+    expectLastCall().anyTimes();
+
+    control.replay();
+
+    handler.handleUpdate(STATUS_NO_REASON
+        .toBuilder()
+        .setMessage("A\nstring\nwith\nmany\nlines")
+        .build());
+    handler.handleUpdate(STATUS_NO_REASON
+        .toBuilder()
+        .setMessage("A string with one line")
+        .build());
+  }
+
+  @Test
   public void testLostAgent() {
     control.replay();