update_engine: Ditch UpdateCheckScheduler, use UpdateCheckAllowed instead.
This change removes the update_check_scheduler module and replaces it
with async requests to the UpdateCheckAllowed policy, done by the
UpdateAttempter directly.
* A new UpdateAttempter::ScheduleUpdates() is used as a replacement for
UpdateCheckScheduler::Run() and rescheduling of periodic checks inside
UpdateCheckScheduler. The callback
UpdateAttempter::OnUpdateScheduled() handles both periodic and
interactive checks.
* The UpdateAttempter keeps track of whether or not an update check is
being waited for (waiting_for_scheduled_check_) so that we can ensure
liveness. This is a similar check to the one performed inside the
UpdateCheckScheduler.
* Inference of the update target version prefix and channel (via device
policy), as well as update disabled, are now performed by the
UpdateManager policy. Also eliminating reference to the list of
network types allowed by policy, which is not enforced anyway and will
be superceded by another policy request (UpdateDownloadAllowed).
* Since update check scheduling is now performed relative to the last
update check time (as recorded by the UpdateAttempter), we care to
update this time as soon as the request is issued (in addition to when
a response is received). This ensures that we won't be scheduling
back-to-back update requests in the case where a response was not
received. Updating the last check time is delegated to a method call;
we replace raw use of time(2) with the ClockInterface abstraction.
* Handling of forced update checks has been revised: the UpdateAttempter
keeps track of the most recent app_version and omaha_url values that
were received through DBus events; it notifies the UpdateManager not
only of whether or not a forced (formerly, "interactive") update
request is pending, but also whether or not it is indeed interactive
or should be treated as a normal periodic one. The UpdateManager
reflects this back to the updater via the result output of
UpdateCheckAllowed, which tells the UpdateManager whether the custom
app_version and omaha_url should be used (interactive) or not.
BUG=chromium:358269
TEST=Unit tests.
Change-Id: Ifa9857b98e58fdd974f91a0fec674fa4472e3a9d
Reviewed-on: https://chromium-review.googlesource.com/209101
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index 0dc0ad6..67799ce 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -168,6 +168,7 @@
const bool* is_boot_device_removable_p = ec->GetValue(
system_provider->var_is_boot_device_removable());
if (is_boot_device_removable_p && *is_boot_device_removable_p) {
+ LOG(INFO) << "Booted from removable device, disabling update checks.";
result->updates_enabled = false;
return EvalStatus::kSucceeded;
}
@@ -178,8 +179,10 @@
// Check whether updates are disabled by policy.
const bool* update_disabled_p = ec->GetValue(
dp_provider->var_update_disabled());
- if (update_disabled_p && *update_disabled_p)
+ if (update_disabled_p && *update_disabled_p) {
+ LOG(INFO) << "Updates disabled by policy, blocking update checks.";
return EvalStatus::kAskMeAgainLater;
+ }
// Determine whether a target version prefix is dictated by policy.
const string* target_version_prefix_p = ec->GetValue(
@@ -199,10 +202,15 @@
}
// First, check to see if an interactive update was requested.
- const bool* interactive_update_requested_p = ec->GetValue(
- updater_provider->var_interactive_update_requested());
- if (interactive_update_requested_p && *interactive_update_requested_p) {
- result->is_interactive = true;
+ const UpdateRequestStatus* forced_update_requested_p = ec->GetValue(
+ updater_provider->var_forced_update_requested());
+ if (forced_update_requested_p &&
+ *forced_update_requested_p != UpdateRequestStatus::kNone) {
+ result->is_interactive =
+ (*forced_update_requested_p == UpdateRequestStatus::kInteractive);
+ LOG(INFO) << "Forced update signaled ("
+ << (result->is_interactive ? "interactive" : "periodic")
+ << "), allowing update check.";
return EvalStatus::kSucceeded;
}
@@ -214,6 +222,7 @@
const bool* is_official_build_p = ec->GetValue(
system_provider->var_is_official_build());
if (is_official_build_p && !(*is_official_build_p)) {
+ LOG(INFO) << "Unofficial build, blocking periodic update checks.";
return EvalStatus::kAskMeAgainLater;
}
@@ -223,8 +232,10 @@
if (is_oobe_enabled_p && *is_oobe_enabled_p) {
const bool* is_oobe_complete_p = ec->GetValue(
system_provider->var_is_oobe_complete());
- if (is_oobe_complete_p && !(*is_oobe_complete_p))
+ if (is_oobe_complete_p && !(*is_oobe_complete_p)) {
+ LOG(INFO) << "OOBE not completed, blocking update checks.";
return EvalStatus::kAskMeAgainLater;
+ }
}
// Ensure that periodic update checks are timed properly.
@@ -233,10 +244,14 @@
EvalStatus::kSucceeded) {
return EvalStatus::kFailed;
}
- if (!ec->IsWallclockTimeGreaterThan(next_update_check))
+ if (!ec->IsWallclockTimeGreaterThan(next_update_check)) {
+ LOG(INFO) << "Periodic check interval not satisfied, blocking until "
+ << chromeos_update_engine::utils::ToString(next_update_check);
return EvalStatus::kAskMeAgainLater;
+ }
// It is time to check for an update.
+ LOG(INFO) << "Allowing update check.";
return EvalStatus::kSucceeded;
}