-
Notifications
You must be signed in to change notification settings - Fork 199
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
Support Installation-Date-based Slot Selection (A/B/C Update) #1525
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1525 +/- ##
==========================================
+ Coverage 83.24% 83.27% +0.02%
==========================================
Files 69 69
Lines 21585 21632 +47
==========================================
+ Hits 17968 18013 +45
- Misses 3617 3619 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still have enough test cases for the per-slot
status cases?
GHashTableIter iter; | ||
|
||
g_return_val_if_fail(rootclass, NULL); | ||
|
||
if (g_strcmp0(r_context()->config->statusfile_path, "per-slot") == 0) { | ||
g_debug("Selecting inactive slot for class '%s'. Fallback strategy: 'first found'", rootclass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g_debug("Selecting inactive slot for class '%s'. Fallback strategy: 'first found'", rootclass); | |
g_debug("Selecting inactive slot for class '%s'. Strategy: 'first found'", rootclass); |
return iterslot; | ||
} | ||
|
||
g_assert_nonnull(iterslot->status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this guaranteed? What happens if the global slot status is empty?
gchar *found = g_date_time_format(iterslot->status->installed_timestamp, RAUC_FORMAT_ISO_8601); | ||
gchar *current = g_date_time_format(selectslot->status->installed_timestamp, RAUC_FORMAT_ISO_8601); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use g_autofree
.
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
When using a global slot status, we can load the status of all slots during RAUC startup. This should happen during (target) context setup. This commit does not change behavior but renames load_slot_status_globally() to r_slot_status_load_globally() and adds the status file name and slot hash table as arguments to allow removing calls to the r_context() method (which is not available during context setup). Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Adds a call to r_slot_status_load_globally() to r_context_configure_target(), just like it already calls r_system_status_load(). This ensures the slot status is loaded initially and the rest of the code can safely assume the status information is filled (when using a global status file). Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Prepares for reworking timestamp handling and ensures using the same format string consistently. For later glib versions, an alternative coulde be to use g_date_time_format_iso8601(). Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Up to now the time was stored as a gchar string in RaucSlotStatus as it was only recorded and never modified or used for any operation. If we now aim to use this time to base further decisions on it, we should be able to properly handle the time as time and not as a string. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
…date) So far, RAUC theoretically supported having three slot groups (e.g. rootfs.0, rootfs.1, rootfs.2), but the slot selection algorithm prevented their use for an A/B/C update. The algorithm simply selected the 'first' inactive slot group. The 'first' group is implementation-defined by the data type used (i.e. by the GHashTable). As a result, updating always alternated between two slot groups. This commit now introduces a slightly more sophisticated slot selection algorithm which always selects the slot group with the oldest installation date. Selecting the oldest installation date automatically ensures that all slots get their turn since once a slot is updated, it has the most recent timestamp and will be selected last. A slot that has no installation date yet is considered outdated. Not that the same behavior can also be used in an A/B setup together with 'rauc.external' to ensure that two consecutive calls of 'rauc install' populate *both* inactive slot groups A and B. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Having a data-directory is the new default, thus we should update older configs to this. It also potentially enhances test coverage for data-directory and allows using it for testing newer features. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
The crypt-test.conf should was meant to be used for the crypt tests. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
With the changes made for timestamp-based slot selection, it is possible to install to both inactive slot groups by calling 'rauc install' twice. This extends the existing test case 'test_install_rauc_external' to cover that, too. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
73bf8fc
to
8143d3f
Compare
Rebased onto |
So far, RAUC theoretically supported having three slot groups (e.g.
rootfs.0
,rootfs.1
,rootfs.2
), but the slot selection algorithm prevented their use for an A/B/C update.The algorithm simply selected the 'first' inactive slot group.
The 'first' group is implementation-defined by the data type used (i.e. by the GHashTable).
As a result, updating always alternated between two slot groups.
This PR now introduces a slightly more sophisticated slot selection algorithm which always selects the slot group with the oldest installation date.
Selecting the oldest installation date automatically ensures that all slots get their turn since once a slot is updated, it has the most recent timestamp and will be selected last.
A slot that has no installation date yet is considered outdated.
Not that the same behavior can also be used in an A/B setup together with
rauc.external
to ensure that two consecutive calls ofrauc install
populate both inactive slot groups A and B.Fixes #1383