Skip to content

Support Installation-Date-based Slot Selection (A/B/C Update) #1525

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

ejoerns
Copy link
Member

@ejoerns ejoerns commented Sep 19, 2024

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 of rauc install populate both inactive slot groups A and B.

Fixes #1383

@ejoerns ejoerns added the enhancement Adds new functionality or enhanced handling to RAUC label Sep 19, 2024
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 89.15663% with 9 lines in your changes missing coverage. Please review.

Project coverage is 84.46%. Comparing base (7b60851) to head (0f76339).
Report is 268 commits behind head on master.

Files with missing lines Patch % Lines
src/install.c 77.77% 6 Missing ⚠️
src/status_file.c 90.47% 2 Missing ⚠️
src/mark.c 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1525      +/-   ##
==========================================
+ Coverage   84.42%   84.46%   +0.04%     
==========================================
  Files          69       69              
  Lines       21663    21710      +47     
==========================================
+ Hits        18288    18337      +49     
+ Misses       3375     3373       -2     
Flag Coverage Δ
service=false 81.04% <55.42%> (-0.09%) ⬇️
service=true 84.38% <89.15%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ejoerns ejoerns changed the title Support Installation Date-based Slot Selection (A/B/C Update) Support Installation-Date-based Slot Selection (A/B/C Update) Oct 16, 2024
Copy link
Member

@jluebbe jluebbe left a 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?

return iterslot;
}

g_assert_nonnull(iterslot->status);
Copy link
Member

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?

@ejoerns
Copy link
Member Author

ejoerns commented Oct 23, 2024

Rebased onto master to resolve conflict in conftest.py (no further changes).

@jluebbe jluebbe added this to the Release v1.14 milestone Oct 30, 2024
@jluebbe
Copy link
Member

jluebbe commented Nov 13, 2024

We should consider selecting bad slots (e.g. due to an interrupted installation) before looking at the dates. Otherwise, repeated installation attempts would lead to all inactive slots being marked as bad.

@ejoerns
Copy link
Member Author

ejoerns commented Nov 29, 2024

Rebased on master and incorporated changes from #1567 and #1572 for now.

@ejoerns ejoerns force-pushed the topic/abc-update branch 2 times, most recently from 58ed4e8 to 749709f Compare November 29, 2024 11:40
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>
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>
This adds a fixture that can be used to test triple-redundancy setups
with RAUC.

Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
@jluebbe jluebbe removed this from the Release v1.14 milestone Apr 2, 2025
@jluebbe jluebbe added this to the Release v1.15 milestone Apr 2, 2025
@jluebbe
Copy link
Member

jluebbe commented Jun 25, 2025

@ejoerns Does the current state address the comments above? If so, please re-request a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds new functionality or enhanced handling to RAUC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how to select install slot on A/B boot when booting from usb (rauc.external)
2 participants