Revert "AMBARI-3770. Need better error log message when agent unable to reach server (Dmytro Shkvyra via dlysnichenko)"

This reverts commit 6ccdcc836fb240fb99e0729dd1fdaa0b451dd8fb.
diff --git a/ambari-agent/src/main/python/ambari_agent/Controller.py b/ambari-agent/src/main/python/ambari_agent/Controller.py
index fbaf0c7..7c51b5f 100644
--- a/ambari-agent/src/main/python/ambari_agent/Controller.py
+++ b/ambari-agent/src/main/python/ambari_agent/Controller.py
@@ -84,13 +84,7 @@
         logger.info("Registering with the server " + pprint.pformat(data))
         response = self.sendRequest(self.registerUrl, data)
         ret = json.loads(response)
-        errors = None
-        if 'errors' in ret.keys():
-          errors = ret['errors']
-        print str(errors)
-        if not (errors == None or errors == ""):
-          logger.error(ret['errors'])
-          return ret
+
         logger.info("Registered with the server with " + pprint.pformat(ret))
         print("Registered with the server")
         self.responseId= int(ret['responseId'])
diff --git a/ambari-agent/src/test/python/TestController.py b/ambari-agent/src/test/python/TestController.py
index 6a36115..2b0e614 100644
--- a/ambari-agent/src/test/python/TestController.py
+++ b/ambari-agent/src/test/python/TestController.py
@@ -55,11 +55,12 @@
 
 
   @patch("json.dumps")
+  @patch("json.loads")
   @patch("time.sleep")
   @patch("pprint.pformat")
   @patch.object(Controller, "randint")
   def test_registerWithServer(self, randintMock, pformatMock, sleepMock,
-                              dumpsMock):
+                              loadsMock, dumpsMock):
 
     out = StringIO.StringIO()
     sys.stdout = out
@@ -67,20 +68,19 @@
     register = MagicMock()
     self.controller.register = register
 
-    self.controller.sendRequest = MagicMock()
+    sendRequest = MagicMock()
+    self.controller.sendRequest = sendRequest
 
     dumpsMock.return_value = "request"
-    self.controller.sendRequest.return_value = '{"errors":"Error text"}'
+    response = {"responseId":1,}
+    loadsMock.return_value = response
 
-    self.assertEqual({'errors': 'Error text'}, self.controller.registerWithServer())
+    self.assertEqual(response, self.controller.registerWithServer())
 
-    self.controller.sendRequest.return_value = '{"responseId":1}'
-    self.assertEqual({"responseId":1}, self.controller.registerWithServer())
-
-    self.controller.sendRequest.return_value = '{"responseId":1, "statusCommands": "commands"}'
+    response["statusCommands"] = "commands"
     self.controller.addToQueue = MagicMock(name="addToQueue")
 
-    self.assertEqual({"responseId":1, "statusCommands": "commands"}, self.controller.registerWithServer())
+    self.assertEqual(response, self.controller.registerWithServer())
     self.controller.addToQueue.assert_called_with("commands")
 
     calls = []
@@ -91,10 +91,10 @@
         raise Exception("test")
       return "request"
 
-    self.controller.sendRequest.return_value = '{"responseId":1}'
+    del response["statusCommands"]
 
     dumpsMock.side_effect = side_effect
-    self.assertEqual({"responseId":1}, self.controller.registerWithServer())
+    self.assertEqual(response, self.controller.registerWithServer())
     self.assertTrue(randintMock.called)
     self.assertTrue(sleepMock.called)
 
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
index 6c4fd69..5e466aa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
@@ -30,9 +30,6 @@
 public class RegistrationResponse {
   @JsonProperty("response")
   private RegistrationStatus response;
-
-  @JsonProperty("errors")
-  private String errors;
   
   //Response id to start with, usually zero.
   @JsonProperty("responseId")
@@ -65,10 +62,6 @@
     this.responseId = responseId;
   }
 
-  public void setErrors(String errors) {
-    this.errors = errors;
-  }  
-  
   @Override
   public String toString() {
     return "RegistrationResponse{" +
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
index 0fa24fd..1aac28e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
@@ -38,7 +38,6 @@
 import org.apache.commons.logging.LogFactory;
 
 import com.google.inject.Inject;
-import org.apache.ambari.server.agent.RegistrationStatus;
 
 /**
  * Agent Resource represents Ambari agent controller.
@@ -76,20 +75,11 @@
   @Produces({MediaType.APPLICATION_JSON})
   public RegistrationResponse register(Register message,
       @Context HttpServletRequest req)
-      throws WebApplicationException, InvalidStateTransitionException {
+      throws WebApplicationException, AmbariException, InvalidStateTransitionException {
     /* Call into the heartbeat handler */
 
-    RegistrationResponse response = null;
-    try {
-      response = hh.handleRegistration(message);
-      LOG.debug("Sending registration response " + response);
-    } catch (AmbariException ex) {
-      response = new RegistrationResponse();
-      response.setResponseId(-1);
-      response.setResponseStatus(RegistrationStatus.FAILED);
-      response.setErrors(ex.getMessage());
-      return response;
-    }
+    RegistrationResponse response = hh.handleRegistration(message);
+    LOG.debug("Sending registration response " + response);
     return response;
   }