aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2016-06-15 13:28:59 -0700
committerAlex Deymo <deymo@google.com>2016-08-04 17:27:26 -0700
commit12c05ee6f9a46253d5f47d1e099086a833be5f5b (patch)
treef3e6016aef4a9f45796535b65ac70fe6f6f564b9
parentb729f5c39691f254beb6fabc185a0db6e47542b9 (diff)
downloadupdate_engine-12c05ee6f9a46253d5f47d1e099086a833be5f5b.tar.gz
Improve logs when the update fails due to source hash mistmatch.
The source hash mismatch at the operation level is the most likelly error when applying an incremental update on top of a modified image. This error can also be caught when re-reading the whole target partition at the end of the update, but if a discrepancy on any operation is found when applying the operations, it will fail earlier. This patch improves the log message when this situation occurs. This is not a common error case so a more verbose error message is acceptable here. Previously, the error message was not giving any clue about why was it failing. Bug: 29163155 Bug: 30510360 TEST=Modified a partition and applied a payload. Error message is nicer. (cherry picked from commit 6714084915ea7b66accf933344b0d4cd042dff3d) Change-Id: I0e7ad33006b0d2475bbb3681ad313fb3eb4b3747
-rw-r--r--payload_consumer/delta_performer.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index e4ba78b1..3131a6e9 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -28,6 +28,7 @@
#include <base/files/file_util.h>
#include <base/format_macros.h>
+#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <brillo/data_encoding.h>
@@ -1048,10 +1049,25 @@ bool ValidateSourceHash(const brillo::Blob& calculated_hash,
brillo::Blob expected_source_hash(operation.src_sha256_hash().begin(),
operation.src_sha256_hash().end());
if (calculated_hash != expected_source_hash) {
- LOG(ERROR) << "Hash verification failed. Expected hash = ";
- utils::HexDumpVector(expected_source_hash);
- LOG(ERROR) << "Calculated hash = ";
- utils::HexDumpVector(calculated_hash);
+ LOG(ERROR) << "The hash of the source data on disk for this operation "
+ << "doesn't match the expected value. This could mean that the "
+ << "delta update payload was targeted for another version, or "
+ << "that the source partition was modified after it was "
+ << "installed, for example, by mounting a filesystem.";
+ LOG(ERROR) << "Expected: sha256|hex = "
+ << base::HexEncode(expected_source_hash.data(),
+ expected_source_hash.size());
+ LOG(ERROR) << "Calculated: sha256|hex = "
+ << base::HexEncode(calculated_hash.data(),
+ calculated_hash.size());
+
+ vector<string> source_extents;
+ for (const Extent& ext : operation.src_extents()) {
+ source_extents.push_back(base::StringPrintf(
+ "%" PRIu64 ":%" PRIu64, ext.start_block(), ext.num_blocks()));
+ }
+ LOG(ERROR) << "Operation source (offset:size) in blocks: "
+ << base::JoinString(source_extents, ",");
return false;
}
return true;