diff options
author | Nikita Ioffe <ioffe@google.com> | 2019-05-13 14:14:37 +0100 |
---|---|---|
committer | Nikita Ioffe <ioffe@google.com> | 2019-05-13 17:13:39 +0100 |
commit | 7af550d73d418b76a2537e5ceced6958d5fd1097 (patch) | |
tree | a77aab969039690a6155addfbfa5f13608aef4ae | |
parent | c180a60681b96458fc810c9e20f26486bed7cd29 (diff) | |
download | apex-7af550d73d418b76a2537e5ceced6958d5fd1097.tar.gz |
apexd: improve logging around triggering a rollback
Test: none
Bug: 132324937
Change-Id: Ib63bb26af3069a3384ae1d10e44511411d82e6a3
-rw-r--r-- | apexd/apexd.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp index 046b8aa4..355934d6 100644 --- a/apexd/apexd.cpp +++ b/apexd/apexd.cpp @@ -119,6 +119,8 @@ static const std::vector<const std::string> kBootstrapApexes = { "com.android.tzdata", }; +static constexpr const int kNumRetriesWhenCheckpointingEnabled = 1; + bool isBootstrapApex(const ApexFile& apex) { return std::find(kBootstrapApexes.begin(), kBootstrapApexes.end(), apex.GetManifest().name()) != kBootstrapApexes.end(); @@ -1605,12 +1607,19 @@ Status unstagePackages(const std::vector<std::string>& paths) { Status rollbackStagedSessionIfAny() { auto session = ApexSession::GetActiveSession(); - if (session.Ok() && session->has_value() && - (*session)->GetState() == SessionState::STAGED) { - return RollbackStagedSession(*(*session)); + if (!session.Ok()) { + return session.ErrorStatus(); } - - return Status::Success(); + if (!session->has_value()) { + LOG(WARNING) << "No session to rollback"; + return Status::Success(); + } + if ((*session)->GetState() == SessionState::STAGED) { + LOG(INFO) << "Rolling back session " << **session; + return RollbackStagedSession(**session); + } + return Status::Fail(StringLog() << "Can't rollback " << **session + << " because it is not in STAGED state"); } Status rollbackActiveSession() { @@ -1701,6 +1710,9 @@ void onStart(CheckpointInterface* checkpoint_service) { LOG(ERROR) << "Failed to check if we need a rollback: " << needs_rollback.ErrorMessage(); } else if (*needs_rollback) { + LOG(INFO) << "Exceeded number of session retries (" + << kNumRetriesWhenCheckpointingEnabled + << "). Starting a rollback"; Status status = rollbackStagedSessionIfAny(); if (!status.Ok()) { LOG(ERROR) @@ -1772,7 +1784,7 @@ StatusOr<std::vector<ApexFile>> submitStagedSession( if (gSupportsFsCheckpoints) { Status checkpoint_status = - gVoldService->StartCheckpoint(1 /* numRetries */); + gVoldService->StartCheckpoint(kNumRetriesWhenCheckpointingEnabled); if (!checkpoint_status.Ok()) { // The device supports checkpointing, but we could not start it; // log a warning, but do continue, since we can live without it. |