Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Issue #4879: Add service for running migration in background. #5142

Merged
merged 1 commit into from
Nov 29, 2019

Conversation

pocmo
Copy link
Contributor

@pocmo pocmo commented Nov 25, 2019

This is the AC part of the background service. Next step is to open the Fenix PR after this is in the next snapshot.

@pocmo pocmo added the 🕵️‍♀️ needs review PRs that need to be reviewed label Nov 25, 2019
@pocmo pocmo requested a review from grigoryk November 25, 2019 14:44
@codecov
Copy link

codecov bot commented Nov 25, 2019

Codecov Report

Merging #5142 into master will decrease coverage by 2.86%.
The diff coverage is 16.12%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #5142      +/-   ##
===========================================
- Coverage     82.97%   80.1%   -2.87%     
+ Complexity     5596    3839    -1757     
===========================================
  Files           534     487      -47     
  Lines         24331   17153    -7178     
  Branches       3629    2529    -1100     
===========================================
- Hits          20189   13741    -6448     
+ Misses         2771    2386     -385     
+ Partials       1371    1026     -345
Impacted Files Coverage Δ Complexity Δ
...ents/support/migration/AbstractMigrationService.kt 0% <0%> (ø) 0 <0> (?)
...lla/components/support/migration/FennecMigrator.kt 84.26% <66.66%> (+1.11%) 21 <0> (-1) ⬇️
...ava/mozilla/components/lib/dataprotect/Keystore.kt 45.61% <0%> (ø) 14% <0%> (ø) ⬇️
...onents/support/android/test/rules/WebserverRule.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...mozilla/components/support/utils/StatusBarUtils.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...ain/java/mozilla/components/service/glean/Glean.kt 62.5% <0%> (ø) 5% <0%> (ø) ⬇️
...ponents/support/migration/MigrationResultsStore.kt 88.88% <0%> (-0.31%) 12% <0%> (-1%)
...mponents/feature/findinpage/view/FindInPageView.kt 0% <0%> (-90.91%) 0% <0%> (-14%)
.../scheduler/workmanager/WorkManagerSyncScheduler.kt 0% <0%> (-88.24%) 0% <0%> (-20%)
...a/components/browser/engine/system/SystemEngine.kt 58.97% <0%> (ø) 6% <0%> (ø) ⬇️
... and 461 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01b2405...994b795. Read the comment docs.

Copy link
Contributor

@grigoryk grigoryk left a comment

Choose a reason for hiding this comment

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

:godmode:

stopSelf()
}

private fun ensureChannelExists(): String {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect this sort of thing to live elsewhere, but i see that we already have similar ensureNotificationGroupAndChannelExists methods elsewhere already... Anyway, that's cleanup for a later date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we could think of a helper maybe. But in this case I hope this code will not stick around forever, so I like it to not spread too much.

override fun onBind(intent: Intent?): IBinder? = null

private suspend fun migrate() {
val results = migrator.migrateAsync().await()
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to emit a glean ping out of this; is that something we can do in a service? or would we need to communicate w/ the host app? It'd be great to not have to worry about making our results Parcelable...

But I guess we can deal with this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should just work. We are already using Glean from some other services (e.g. media).

@@ -236,28 +239,52 @@ class FennecMigrator private constructor(
* @return A deferred [MigrationResults], describing which migrations were performed and if they succeeded.
*/
fun migrateAsync(): Deferred<MigrationResults> = synchronized(migrationLock) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be internal now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Gecko migration piece is still called from the app code directly.

}
}

private fun getMigrationsToRun(): List<VersionedMigration> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little worried that this is now not protected by the migrationLock; we shouldn't have overlapping migrations running, of course...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, overlapping migrations could cause a bunch of other issues.

It's private and still protected by the lock when called from migrateAsync(). I think I'll add the same protection to startMigrationServiceIfNeeded().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe not! If a migration is currently running then we do not want to block here - because that can take a while. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I want to land as-is. Once we have #4872 it will be easier to communicate the current state.

@pocmo
Copy link
Contributor Author

pocmo commented Nov 29, 2019

bors r=grigoryk

bors bot pushed a commit that referenced this pull request Nov 29, 2019
5142: Issue #4879: Add service for running migration in background. r=grigoryk a=pocmo

This is the AC part of the background service. Next step is to open the Fenix PR after this is in the next snapshot.

Co-authored-by: Sebastian Kaspari <s.kaspari@gmail.com>
@bors
Copy link

bors bot commented Nov 29, 2019

Build succeeded

  • complete-push

@bors bors bot merged commit 994b795 into mozilla-mobile:master Nov 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🕵️‍♀️ needs review PRs that need to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants