Commit 6ca0cdcb authored by Christos Froussios's avatar Christos Froussios Committed by Commit Bot

[Password Manager] More metrics for LinuxPasswordsMigrationToEncryptionStatus

We see significant numbers of failures. There are many steps where the
migration can fail, so we will distinguish them to identify the fragile step.

Bug: 571003
Change-Id: I23703898d86fcc3ad714228ac8dbeb5ec7e4589b
Reviewed-on: https://chromium-review.googlesource.com/c/1280766Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Christos Froussios <cfroussios@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610875}
parent 9bddb3ff
......@@ -88,6 +88,16 @@ password_manager::metrics_util::LinuxBackendMigrationStatus StepForMetrics(
return LinuxBackendMigrationStatus::kCopiedAll;
case PasswordStoreX::LOGIN_DB_REPLACED:
return LinuxBackendMigrationStatus::kLoginDBReplaced;
case PasswordStoreX::STARTED:
return LinuxBackendMigrationStatus::kStarted;
case PasswordStoreX::POSTPONED:
return LinuxBackendMigrationStatus::kPostponed;
case PasswordStoreX::FAILED_CREATE_ENCRYPTED:
return LinuxBackendMigrationStatus::kFailedCreatedEncrypted;
case PasswordStoreX::FAILED_ACCESS_NATIVE:
return LinuxBackendMigrationStatus::kFailedAccessNative;
case PasswordStoreX::FAILED_REPLACE:
return LinuxBackendMigrationStatus::kFailedReplace;
}
NOTREACHED();
return LinuxBackendMigrationStatus::kNotAttempted;
......@@ -359,11 +369,15 @@ void PasswordStoreX::CheckMigration() {
base::Time::Now() - migration_to_native_started);
if (base::FeatureList::IsEnabled(
password_manager::features::kMigrateLinuxToLoginDB) &&
backend_) {
password_manager::features::kMigrateLinuxToLoginDB)) {
// Copy passwords from the backend into the login database, using
// encryption.
if (backend_) {
UpdateMigrationToLoginDBStep(STARTED);
MigrateToEncryptedLoginDB();
} else {
UpdateMigrationToLoginDBStep(POSTPONED);
}
}
}
......@@ -430,7 +444,7 @@ void PasswordStoreX::MigrateToEncryptedLoginDB() {
if (!encrypted_login_db->Init()) {
VLOG(1) << "Failed to init the encrypted database file. Migration "
"aborted.";
UpdateMigrationToLoginDBStep(FAILED);
UpdateMigrationToLoginDBStep(FAILED_CREATE_ENCRYPTED);
return; // Serve from the native backend.
}
......@@ -438,7 +452,7 @@ void PasswordStoreX::MigrateToEncryptedLoginDB() {
VLOG(1) << "Migrating all passwords to the encrypted database. Last status: "
<< migration_to_login_db_step_;
UpdateMigrationToLoginDBStep(CopyBackendToLoginDB(encrypted_login_db.get()));
if (migration_to_login_db_step_ == FAILED) {
if (migration_to_login_db_step_ != COPIED_ALL) {
VLOG(1) << "Migration to encryption failed.";
base::DeleteFile(encrypted_login_db_file_, false);
return;
......@@ -454,7 +468,7 @@ void PasswordStoreX::MigrateToEncryptedLoginDB() {
// Move the new database onto the old.
if (!base::Move(encrypted_login_db_file_, login_db_file_)) {
LOG(ERROR) << "Could not replace login database.";
UpdateMigrationToLoginDBStep(FAILED);
UpdateMigrationToLoginDBStep(FAILED_REPLACE);
base::DeleteFile(encrypted_login_db_file_, false);
return; // Serve from the native backend.
}
......@@ -488,17 +502,17 @@ PasswordStoreX::MigrationToLoginDBStep PasswordStoreX::CopyBackendToLoginDB(
if (!login_db->DeleteAndRecreateDatabaseFile()) {
LOG(ERROR) << "Failed to create the encrypted login database file";
return FAILED;
return FAILED_CREATE_ENCRYPTED;
}
std::vector<std::unique_ptr<PasswordForm>> forms;
if (!backend_->GetAllLogins(&forms))
return FAILED;
return FAILED_ACCESS_NATIVE;
for (auto& form : forms) {
PasswordStoreChangeList changes = login_db->AddLogin(*form);
if (changes.empty() || changes.back().type() != PasswordStoreChange::ADD) {
return FAILED;
return FAILED_CREATE_ENCRYPTED;
}
}
......
......@@ -41,6 +41,16 @@ class PasswordStoreX : public password_manager::PasswordStoreDefault {
COPIED_ALL,
// The standard login database is encrypted.
LOGIN_DB_REPLACED,
// The migration is about to be attempted.
STARTED,
// No access to the native backend.
POSTPONED,
// Could not create or write into the temporary file.
FAILED_CREATE_ENCRYPTED,
// Could not read from the native backend.
FAILED_ACCESS_NATIVE,
// Could not replace old database.
FAILED_REPLACE,
};
// NativeBackends more or less implement the PaswordStore interface, but
......
......@@ -740,7 +740,12 @@ TEST_P(PasswordStoreXTest, MigrationToEncryption) {
EXPECT_TRUE(stored_forms.empty());
EXPECT_EQ(PasswordStoreX::LOGIN_DB_REPLACED,
migration_step_pref_.GetValue());
} else {
} else if (GetParam() == FAILING_BACKEND) {
// No values should be written if we can't read the backend.
auto stored_forms = ReadLoginDB(test_encrypted_login_db_file_path(), true);
EXPECT_TRUE(stored_forms.empty());
EXPECT_THAT(migration_step_pref_.GetValue(), PasswordStoreX::POSTPONED);
} else { // NO_BACKEND
// No values should be moved without a working backend.
auto stored_forms = ReadLoginDB(test_encrypted_login_db_file_path(), true);
EXPECT_TRUE(stored_forms.empty());
......
......@@ -287,7 +287,17 @@ enum class LinuxBackendMigrationStatus {
kCopiedAll = 2,
// The standard login database is encrypted.
kLoginDBReplaced = 3,
kMaxValue = kLoginDBReplaced
// The migration is about to be attempted.
kStarted = 4,
// No access to the native backend.
kPostponed = 5,
// Could not create or write into the temporary file.
kFailedCreatedEncrypted = 6,
// Could not read from the native backend.
kFailedAccessNative = 7,
// Could not replace old database.
kFailedReplace = 8,
kMaxValue = kFailedReplace
};
// Type of the password drop-down shown on focus field.
......
......@@ -28769,6 +28769,11 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="1" label="Failed"/>
<int value="2" label="Copied everything"/>
<int value="3" label="The standard login database is encrypted"/>
<int value="4" label="The migration is about to be attempted"/>
<int value="5" label="No access to the native backend"/>
<int value="6" label="Could not create or write into the temporary file"/>
<int value="7" label="Could not read from the native backend"/>
<int value="8" label="Could not replace old database"/>
</enum>
<enum name="LinuxSandboxStatus">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment