Skip to content
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

MEN-7804 - handle no files in artifact #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danielskinstad
Copy link
Collaborator

Due to artifact_read_data_prepare not being called when an artifact doesn't have any files, the update module might be NULL after mender_http_artifact_download returns MENDER_OK.

Add an explicit check to ensure this is caught.

Changelog: None
Ticket: MEN-7804

core/src/mender-artifact-download.c Outdated Show resolved Hide resolved
@danielskinstad danielskinstad force-pushed the no-file branch 4 times, most recently from f7aea99 to 3aeaa60 Compare January 31, 2025 13:24
@danielskinstad
Copy link
Collaborator Author

Didn't find a better/simpler way to check if the artifact had a file - lmk if you have a better solution

@danielskinstad danielskinstad changed the title fix: check that the update module is set in mender_download_artifact MEN-7804 - handle no files in artifact Jan 31, 2025
core/src/mender-zephyr-image-update-module.c Outdated Show resolved Hide resolved
core/src/mender-artifact.c Outdated Show resolved Hide resolved
core/src/mender-artifact.c Outdated Show resolved Hide resolved
core/src/mender-zephyr-image-update-module.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

Looks good to me either way.

@@ -136,6 +139,12 @@ mender_zephyr_image_set_pending_image(MENDER_NDEBUG_UNUSED mender_update_state_t
assert(MENDER_UPDATE_STATE_INSTALL == state);
mender_err_t ret;

if (!artifact_has_payload) {
mender_log_error("No file in artifact");
Copy link
Collaborator

@vpodzime vpodzime Feb 3, 2025

Choose a reason for hiding this comment

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

No payload in artifact, maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

@@ -29,6 +29,8 @@
*/
static void *mcu_boot_flash_handle = NULL;

static bool artifact_has_payload;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd actually name this artifact_had_payload as that reflects that it's only valid after an artifact was processed.

Setting the update module when preparing the data is too late - and it
can lead to unexpected behaviour in the state machine if the artifact
doesn't contain files.

Changelog: None
Ticket: MEN-7804

Signed-off-by: Daniel Skinstad Drabitzius <[email protected]>
Check if the aritfact has a payload file by adding a boolean that's set
when the download artifact flash callback is called.

Ticket: MEN-7804

Signed-off-by: Daniel Skinstad Drabitzius <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants