-
Notifications
You must be signed in to change notification settings - Fork 168
Updated tracking / transitions of the task's version state. #9127
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
base: master
Are you sure you want to change the base?
Changes from all commits
73e5dc0
9d33899
de6d689
95fe45c
6a43100
3f20bac
8508e6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,13 +101,12 @@ Future<(CreateInstancesState, Duration)> runOneCreateInstancesCycle( | |
| final instanceName = compute.generateInstanceName(); | ||
| final zone = pickZone(); | ||
|
|
||
| final updated = await updatePackageStateWithPendingVersions( | ||
| final payload = await updatePackageStateWithPendingVersions( | ||
| db, | ||
| selected.package, | ||
| zone, | ||
| instanceName, | ||
| ); | ||
| final payload = updated?.$1; | ||
| if (payload == null) { | ||
| return; | ||
| } | ||
|
|
@@ -174,15 +173,13 @@ Future<(CreateInstancesState, Duration)> runOneCreateInstancesCycle( | |
| banZone(zone, minutes: 15); | ||
| } | ||
| if (rollbackPackageState) { | ||
| final oldVersionsMap = updated?.$2 ?? const {}; | ||
| // Restore the state of the PackageState for versions that were | ||
| // Restire the state of the PackageState for versions that were | ||
| // suppose to run on the instance we just failed to create. | ||
| // If this doesn't work, we'll eventually retry. Hence, correctness | ||
| // does not hinge on this transaction being successful. | ||
| await db.tasks.restorePreviousVersionsState( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure we shouldn't have a method for this, should be inline logic. There is never a reason to call Also you cannot look at if we want it as a method, then it should be a helper method in this file, like Why can't we simply store |
||
| selected.package, | ||
| instanceName, | ||
| oldVersionsMap, | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -221,11 +218,8 @@ Future<(CreateInstancesState, Duration)> runOneCreateInstancesCycle( | |
|
|
||
| /// Updates the package state with versions that are already pending or | ||
| /// will be pending soon. | ||
| /// | ||
| /// Returns the payload and the old status of the state info version map | ||
| @visibleForTesting | ||
| Future<(Payload, Map<String, PackageVersionStateInfo>)?> | ||
| updatePackageStateWithPendingVersions( | ||
| Future<Payload?> updatePackageStateWithPendingVersions( | ||
| DatastoreDB db, | ||
| String package, | ||
| String zone, | ||
|
|
@@ -237,7 +231,6 @@ updatePackageStateWithPendingVersions( | |
| // presumably the package was deleted. | ||
| return null; | ||
| } | ||
| final oldVersionsMap = {...?s.versions}; | ||
|
|
||
| final now = clock.now(); | ||
| final pendingVersions = derivePendingVersions( | ||
|
|
@@ -253,13 +246,11 @@ updatePackageStateWithPendingVersions( | |
| // Update PackageState | ||
| s.versions!.addAll({ | ||
| for (final v in pendingVersions.map((v) => v.toString())) | ||
| v: PackageVersionStateInfo( | ||
| v: s.versions![v]!.scheduleNew( | ||
| scheduled: now, | ||
isoos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| attempts: s.versions![v]!.attempts + 1, | ||
| zone: zone, | ||
| instance: instanceName, | ||
| instanceName: instanceName, | ||
| secretToken: createUuid(), | ||
| finished: s.versions![v]!.finished, | ||
| ), | ||
| }); | ||
| s.pendingAt = derivePendingAt( | ||
|
|
@@ -279,6 +270,6 @@ updatePackageStateWithPendingVersions( | |
| ), | ||
| ), | ||
| ); | ||
| return (payload, oldVersionsMap); | ||
| return payload; | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.