Retries getting status of update_engine on error before giving up.
Since the update_engine is single threaded, sometimes the operations (like
system write) take too long time and this prevents the update_engine from
resonding to dbus signals. Retrying when the status is "dbus signal failure"
might alleviate the problem. (This CL does not handle the error codes).
BUG=chromium:738024
TEST=none
Change-Id: Ic1b7816b797d84fc6a8c7c7540ddaa22cd3d4d1b
Reviewed-on: https://chromium-review.googlesource.com/556356
Commit-Ready: Grant Grundler <grundler@chromium.org>
Tested-by: Lann Martin <lannm@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
diff --git a/update_engine_client.cc b/update_engine_client.cc
index 44897e0..f337dd6 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -14,6 +14,13 @@
// limitations under the License.
//
+#include <base/bind.h>
+#include <base/command_line.h>
+#include <base/logging.h>
+#include <base/macros.h>
+#include <brillo/daemons/daemon.h>
+#include <brillo/flag_helper.h>
+
#include <inttypes.h>
#include <sysexits.h>
#include <unistd.h>
@@ -22,13 +29,6 @@
#include <string>
#include <vector>
-#include <base/bind.h>
-#include <base/command_line.h>
-#include <base/logging.h>
-#include <base/macros.h>
-#include <brillo/daemons/daemon.h>
-#include <brillo/flag_helper.h>
-
#include "update_engine/client.h"
#include "update_engine/common/error_code.h"
#include "update_engine/common/error_code_utils.h"
@@ -52,6 +52,11 @@
// initialization.
const int kContinueRunning = -1;
+// The ShowStatus request will be retried `kShowStatusRetryCount` times at
+// `kShowStatusRetryInterval` second intervals on failure.
+const int kShowStatusRetryCount = 30;
+const int kShowStatusRetryInterval = 2;
+
class UpdateEngineClient : public brillo::Daemon {
public:
UpdateEngineClient(int argc, char** argv) : argc_(argc), argv_(argv) {
@@ -151,9 +156,17 @@
string new_version;
int64_t new_size = 0;
- if (!client_->GetStatus(&last_checked_time, &progress, ¤t_op,
- &new_version, &new_size)) {
- return false;
+ int retry_count = kShowStatusRetryCount;
+ while (retry_count > 0) {
+ if (client_->GetStatus(&last_checked_time, &progress, ¤t_op,
+ &new_version, &new_size)) {
+ break;
+ }
+ if (--retry_count == 0) {
+ return false;
+ }
+ LOG(WARNING) << "Trying " << retry_count << " more times";
+ sleep(kShowStatusRetryInterval);
}
printf("LAST_CHECKED_TIME=%" PRIi64