Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not delete target wallet, do not fail migration on item-error #1006

Merged
merged 4 commits into from
Oct 3, 2023

Conversation

Patrik-Stas
Copy link
Contributor

@Patrik-Stas Patrik-Stas commented Oct 3, 2023

This is set of changes to make the migration.

  • More graceful, one migration error should not halt migration of the rest. It's up to migrating user to evaluate whether the migration result is satisfactory.
  • Idempotent - if migration fails for example due an IO error midway, it should be possible to finish it on 2nd try.

Changes:

  • If migration fails, do not delete the target wallet.
  • Disable adding records to vdrtool cache when running migration.
  • Do not fail migration if the record has unexpected format. Just skip it and log the record.
  • If migration of the record itself fail, skip it and log.
  • If adding item to target wallet fails due duplication error, skip it. For idempotency it would be ideal to overwrite it, but that would need digging deeper. For now, skipping these records still gives us idempotency under assumption item migration process was not changed between 2 migrations attempts.
  • If adding item fails for other reason, fail the migration (likely IO error).

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

Merging #1006 (b572afc) into main (725797b) will decrease coverage by 0.02%.
The diff coverage is 13.63%.

@@            Coverage Diff             @@
##             main    #1006      +/-   ##
==========================================
- Coverage   30.39%   30.38%   -0.02%     
==========================================
  Files         422      422              
  Lines       26227    26242      +15     
  Branches     5084     5085       +1     
==========================================
+ Hits         7972     7973       +1     
- Misses      16038    16051      +13     
- Partials     2217     2218       +1     
Flag Coverage Δ
unittests-aries-vcx 30.38% <13.63%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
libvdrtools/indy-wallet/src/export_import.rs 0.00% <ø> (ø)
libvdrtools/src/controllers/wallet.rs 32.30% <ø> (ø)
libvdrtools/indy-wallet/src/wallet.rs 48.08% <66.66%> (+0.01%) ⬆️
...ibvdrtools/indy-api-types/src/domain/wallet/mod.rs 7.14% <0.00%> (-0.55%) ⬇️
libvdrtools/indy-wallet/src/lib.rs 48.12% <8.33%> (-0.88%) ⬇️

@Patrik-Stas Patrik-Stas force-pushed the credx/migration-tweaks branch from 73813f4 to 880734e Compare October 3, 2023 07:05
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
@Patrik-Stas Patrik-Stas force-pushed the credx/migration-tweaks branch from 880734e to 0659b2f Compare October 3, 2023 07:06
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
Copy link
Contributor

@bobozaur bobozaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand that this helped in troubleshooting some issues (practically unrelated to the migration code) I think most changes (maybe apart from logging) should be reverted.

The fact that the migrator cleans up after itself on failure might not be a big deal for us, but it probably is for consumers that will use it.

Likewise, I don't think the migration should just continue on record errors. This is important data and I personally believe that anything that does not go well should be manually investigated and dealt with and the migration re-attempted afterwards, essentially succeeding only if everything is in order.

Comment on lines -294 to -305
if let Err(e) = migration_res {
close_wallet(dest_wallet_handle).await.ok();
delete_wallet(wallet_config).await.ok();
Err(LibvcxError::from_msg(
LibvcxErrorKind::WalletMigrationFailed,
e,
))
} else {
setup_wallet(dest_wallet_handle)?;
close_wallet(src_wallet_handle).await?;
Ok(())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not delete the destination wallet on failure?

Copy link
Contributor Author

@Patrik-Stas Patrik-Stas Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to rerun migration against the same target repeatedly, with predictable result. If I get IO error midway, I want to be able to retry.

Comment on lines +192 to +194
if cache_record {
self.cache.add(type_, &etype, &ename, &evalue, &etags);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change supposed to do? I see the flag is set to true in both instances where this is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In migration, the flag is set to false.

Comment on lines 285 to 288
info!(
"Creating or opening target wallet {}",
&wallet_config.wallet_name
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will always attempt to create it.

@Patrik-Stas
Copy link
Contributor Author

Patrik-Stas commented Oct 3, 2023

While I understand that this helped in troubleshooting some issues (practically unrelated to the migration code) I think most changes (maybe apart from logging) should be reverted.

The fact that the migrator cleans up after itself on failure might not be a big deal for us, but it probably is for consumers that will use it.

If migration fails, you might want to inspect the wallet

Likewise, I don't think the migration should just continue on record errors. This is important data and I personally believe that anything that does not go well should be manually investigated and dealt with and the migration re-attempted afterwards, essentially succeeding only if everything is in order.

If you fail on first error, you don't even get to know all the problem you have, only the first one. The changed approach in this PR provide flexibility to migrators. You can but don't have to be strict about failures, it's your call based on MigrationResult. In case of libvcx, as the only users, I chose the approach of being relaxed about it and decide on upper level of abstractions.

Also, I don't think there's at the moment other users of this migration other than us. George is already using credx. As the user of the migration code, these were practically useful changes I'd suggest to merge, although most of this will be anyways deleted in subsequent commits, as we remove vdrtools anoncreds.

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
@Patrik-Stas Patrik-Stas force-pushed the credx/migration-tweaks branch from 9865772 to 0c8a2a9 Compare October 3, 2023 12:43
bobozaur
bobozaur previously approved these changes Oct 3, 2023
Copy link
Contributor

@bobozaur bobozaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got mixed up in the files being modified and forgot the design of the migration. Given that this affects libvcx stuff, I think the changes are then warranted. Thanks for clarifying!

Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
@Patrik-Stas Patrik-Stas merged commit 34c35de into main Oct 3, 2023
33 of 38 checks passed
@Patrik-Stas Patrik-Stas deleted the credx/migration-tweaks branch October 3, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants