8000 add polling support by jluebbe · Pull Request #1672 · rauc/rauc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add polling support #1672

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 10 commits into
base: master
Choose a base branch
from
Open

add polling support #1672

wants to merge 10 commits into from

Conversation

jluebbe
Copy link
Member
@jluebbe jluebbe commented Mar 21, 2025

This is based on the concept described in #1114.

Documentation:

TODO:

@jluebbe jluebbe added the enhancement Adds new functionality or enhanced handling to RAUC label Mar 21, 2025
@jluebbe jluebbe self-assigned this Mar 21, 2025
Copy link
codecov bot commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 83.40807% with 74 lines in your changes missing coverage. Please review.

Project coverage is 84.47%. Comparing base (6ee3731) to head (5652b19).

Files with missing lines Patch % Lines
src/polling.c 88.69% 38 Missing ⚠️
src/config_file.c 59.72% 29 Missing ⚠️
src/utils.c 70.00% 6 Missing ⚠️
src/context.c 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1672      +/-   ##
==========================================
- Coverage   84.48%   84.47%   -0.01%     
==========================================
  Files          76       77       +1     
  Lines       22286    22730     +444     
==========================================
+ Hits        18828    19201     +373     
- Misses       3458     3529      +71     
Flag Coverage Δ
service=false 79.41% <3.58%> (-1.56%) ⬇️
service=true 84.43% <83.40%> (-0.01%) ⬇️

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.

src/poll.c Outdated
Comment on lines 321 to 338
const gchar *cmd = r_context()->config->poll_reboot_cmd;
g_assert(cmd);
Copy link
Member

Choose a reason for hiding this comment

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

I am currently experimenting with the feature. According to the documentation setting a reboot-cmd is optional and the default (reboot) should be used if none is set, but I've hit this assertion with no (reboot-cmd) set in the config.

Mar 26 13:18:50 lxatac-00011 rauc[541]: polling: installation of `http://192.168.94.2:40080/update.raucb` succeeded
Mar 26 13:18:50 lxatac-00011 rauc[541]: scheduled next poll in: 15s
Mar 26 13:19:05 lxatac-00011 rauc[541]: **
Mar 26 13:19:05 lxatac-00011 rauc[541]: rauc:ERROR:/usr/src/debug/rauc/1.13+git/src/poll.c:322:poll_reboot: assertion failed: (cmd)
Mar 26 13:19:05 lxatac-00011 rauc[541]: Bail out! rauc:ERROR:/usr/src/debug/rauc/1.13+git/src/poll.c:322:poll_reboot: assertion failed: (cmd)
Mar 26 13:19:07 lxatac-00011 systemd[1]: rauc.service: Main process exited, code=dumped, status=6/ABRT
Mar 26 13:19:07 lxatac-00011 systemd[1]: rauc.service: Failed with result 'core-dump

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, the default is missing.

@hnez
Copy link
Member
hnez commented Mar 26, 2025

From using the feature it does not look like there is a lot of debug output (by default default) about which candidate-/install-/reboot-criteria are met by a polled bundle and which are not.
I think that would be useful.

Something along the lines of:

Not considered because of unmet criterium: …

@jluebbe jluebbe added this to the Release v1.15 milestone Apr 1, 2025
hnez added a commit to hnez/meta-lxatac that referenced this pull request Apr 2, 2025
Update the source revision to the current master branch tip and apply
the polling support pull request[1] on top of it.
The PR is applied as patches instead of an updated SRCREV because the
PR branch is very likely to be force-pushed again.

[1]: rauc/rauc#1672

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
hnez added a commit to hnez/meta-lxatac that referenced this pull request Apr 3, 2025
Update the source revision to the v14.1 release and apply the polling
support pull request[1] on top of it.
The PR is applied as patches instead of an updated SRCREV because the
PR branch is very likely to be force-pushed again.

[1]: rauc/rauc#1672

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
jluebbe added 6 commits April 30, 2025 09:49
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
This will allow us to determine if a reboot should be performed after an
automatic installation.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
The helper also optionally checks the strings against an allow-list.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
This is useful for testing handling of aspects like 204 no content.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
test/conftest.py Outdated
@@ -147,6 +147,7 @@ def _have_faketime():


no_service = pytest.mark.skipif(string_in_config_h("ENABLE_SERVICE 1"), reason="Have service")
needs_service = pytest.mark.skipif(not string_in_config_h("ENABLE_SERVICE 1"), reason="Have service")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
needs_service = pytest.mark.skipif(not string_in_config_h("ENABLE_SERVICE 1"), reason="Have service")
needs_service = pytest.mark.skipif(not string_in_config_h("ENABLE_SERVICE 1"), reason="Need service")



def test_poll_only(create_system_files, system, http_server):
"""Test if the info command sends custom headers correctly."""
Copy link
Member

Choose a reason for hiding this comment

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

I think the docstrings in this file are not up to date.

Comment on lines 636 to 646
[poll]
source=https://example.com/stable/my_product.raucb
interval-sec=300
max-interval-sec=3600

In this example:

* RAUC polls the source every 5 minutes as long as no error occurs.
* Every time a poll attempt fails, the interval is increased by 5 minutes, until
it reaches 1 hour.
* If an attempt is successful again, the interval is reduced to 5 minutes.
Copy link
Member

Choose a reason for hiding this comment

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

The documentation should contain best practices. Polling every five minutes sounds excessive to me.

How about e.g.

   interval-sec=14400
   max-interval-sec=86400

e.g. four hours and one day respectively. Four hours still sounds a bit too frequent for my taste, but at least hacker news will not make fun of it.

Comment on lines +406 to +415
``candidate-criteria`` (optional, default is ``higher-semver``)
Specifies the conditions under which a new bundle is considered a **candidate**
for updating.
These conditions do **not** automatically trigger the installation of the
update.

Supported values are:

* ``higher-semver``: The new bundle's version (interpreted as a Semantic
Version) is higher than the current system version.
* ``different-version``: The new bundle's version string differs from the
current system version (regardless of ordering).
Copy link
Member

Choose a reason for hiding this comment

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

I use the DBus poller status property to get the compatible, version, manifest_hash and effective_url of the remote bundle. I want these (and the other fields I do not use) to always be up to date with the results of the previous poll.

I did not yet fully grasp if that is the case, or if this information is only available if candidate-criteria matches.
Should I set candidate-criteria= (empty) in order to also see the remote bundle information via the status property if the semver of the current image and the remote bundle happen to match?

(The code in question, if you are interested linux-automation/tacd@0ab21a3 linux-automation/tacd@911e489)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. We should rethink the behavior here. It could still be useful to expose the manifest even if the poller decides this version is not a candidate. The decision should be exposed in this case as well.

This aspect probably also needs some specific documentation.

@jluebbe
Copy link
Member Author
jluebbe commented Apr 30, 2025

@ejoerns @hnez Which clock base should we use for the last-attempt-time and last-sucess-time properties (CLOCK_MONOTONIC, CLOCK_BOOTTIME or CLOCK_REALTIME)? As polling may happen before the clock is synchronized, CLOCK_REALTIME may be ambiguous. With CLOCK_BOOTTIME, we could calculate how much time passed since the last attempt.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
@jluebbe
Copy link
Member Author
jluebbe commented Apr 30, 2025

I've renamed the [poll] section to [polling] as discussed internally. The related function and variable names have been changed as well.

jluebbe added 2 commits April 30, 2025 17:54
This implements large parts of rauc#1114 (Simple Update Server Support).

The polling functionality in RAUC allows a device to periodically check
for updates from a specified source. It fetches bundle manifests, checks
for available updates, and initiates installations if necessary. This
functionality is intended to automate the update process and ensure that
the system remains up-to-date with minimal manual intervention.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
< F6E5 summary role="button" data-target="details-collapsible.summaryElement details-toggle.summaryTarget" data-action="click:details-collapsible#toggle click:details-toggle#toggle" data-aria-label-closed="Expand comment" data-aria-label-open="Collapse comment" aria-expanded="true" aria-label="Collapse comment" data-view-component="true" class="py-2 px-3 rounded-2 color-bg-subtle">
NULL
};

static gboolean parse_polling_config(RaucConfig *config, GKeyFile *key_file, GError **error)

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 122 lines.
@jluebbe
Copy link
Member Author
jluebbe commented Apr 30, 2025

The last force-push now also renames the new source files.

@jluebbe jluebbe requested review from hnez and ejoerns April 30, 2025 16:09
@jluebbe jluebbe marked this pull request as ready for review May 13, 2025 10:04
@jluebbe
Copy link
Member Author
jluebbe commented May 13, 2025

@ejoerns @hnez Perhaps we should (by default) delay installation until the current slot was marked good?

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.

2 participants
0