[moblab] Show update errors on UI
If a user requests an update from the UI, and the update fails,
surface the error to the UI.
BUG=chromium:806311
TEST=test on local moblab, forced an update error by setting the
omaha url to an unresolvable address
Change-Id: I425a8013a1df1e09f9a8e8b821f5afb76496eb58
Reviewed-on: https://chromium-review.googlesource.com/909330
Commit-Ready: Matt Mallett <mattmallett@chromium.org>
Tested-by: Matt Mallett <mattmallett@chromium.org>
Reviewed-by: Keith Haddow <haddowk@chromium.org>
(cherry picked from commit 1674447ddd7815b1ac463a37084afbbcc8ea86e1)
Reviewed-on: https://chromium-review.googlesource.com/912173
Commit-Queue: Matt Mallett <mattmallett@chromium.org>
Trybot-Ready: Matt Mallett <mattmallett@chromium.org>
diff --git a/frontend/afe/moblab_rpc_interface.py b/frontend/afe/moblab_rpc_interface.py
index 12beb71..2bc923b 100644
--- a/frontend/afe/moblab_rpc_interface.py
+++ b/frontend/afe/moblab_rpc_interface.py
@@ -530,8 +530,9 @@
subprocess.call(['sudo', _UPDATE_ENGINE_CLIENT, '--reboot'])
except subprocess.CalledProcessError as e:
- pass
- #TODO(crbug/806311) surface error to UI
+ update_error = subprocess.check_output(
+ ['sudo', _UPDATE_ENGINE_CLIENT, '--last_attempt_error'])
+ raise error.RPCException(update_error)
@rpc_utils.moblab_only
diff --git a/frontend/afe/moblab_rpc_interface_unittest.py b/frontend/afe/moblab_rpc_interface_unittest.py
index 2eafe71..dc40da4 100644
--- a/frontend/afe/moblab_rpc_interface_unittest.py
+++ b/frontend/afe/moblab_rpc_interface_unittest.py
@@ -506,6 +506,30 @@
self.mox.ReplayAll()
moblab_rpc_interface._install_system_update()
+ def testInstallSystemUpdateError(self):
+ update_engine_client = moblab_rpc_interface._UPDATE_ENGINE_CLIENT
+
+ error_message = ('ERROR_CODE=37\n'
+ 'ERROR_MESSAGE=ErrorCode::kOmahaErrorInHTTPResponse')
+
+ self.mox.StubOutWithMock(moblab_rpc_interface.subprocess, 'check_call')
+ moblab_rpc_interface.subprocess.check_call(['sudo',
+ update_engine_client, '--update']).AndRaise(
+ moblab_rpc_interface.subprocess.CalledProcessError(1,
+ 'sudo'))
+
+ self.mox.StubOutWithMock(moblab_rpc_interface.subprocess,
+ 'check_output')
+ moblab_rpc_interface.subprocess.check_output(['sudo',
+ update_engine_client, '--last_attempt_error']).AndReturn(
+ error_message)
+
+ self.mox.ReplayAll()
+ try:
+ moblab_rpc_interface._install_system_update()
+ except moblab_rpc_interface.error.RPCException as e:
+ self.assertEquals(str(e), error_message)
+
def testGetSystemUpdateStatus(self):
update_engine_client = moblab_rpc_interface._UPDATE_ENGINE_CLIENT