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

Bugfix/download only response #160

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/hawkbit-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef struct Artifact_ {
gchar *download_url; /**< download URL of software bundle file */
gchar *feedback_url; /**< URL status feedback should be sent to */
gchar *sha1; /**< sha1 checksum of software bundle file */
gchar *maintenance_window; /**< maintenance flag, possible values: available, unavailable, null */
gboolean do_install; /**< whether the installation should be started or not */
} Artifact;

Expand Down
13 changes: 13 additions & 0 deletions src/hawkbit-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,17 @@ static gpointer download_thread(gpointer data)
}

g_mutex_lock(&active_action->mutex);
// skip installation if hawkBit asked us to do so
if (!artifact->do_install &&
(!artifact->maintenance_window || g_strcmp0(artifact->maintenance_window, "available") == 0)) {
active_action->state = ACTION_STATE_SUCCESS;
Copy link
Member

Choose a reason for hiding this comment

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

Does this change anything, really?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. You mean that feedback alone would suffice?

Copy link
Member

Choose a reason for hiding this comment

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

The active_action->state is for the rauc-hawkbit-updater internal state machine only. I think it's correct to set it to ACTION_STATE_SUCCESS here.

While looking at this, I think we should revisit the code paths setting it back to the initial ACTION_STATE_NONE (effectively sending acknowledgements on cancel requests). This does not look correct for all the cases.

if (!feedback(artifact->feedback_url, active_action->id, "File checksum OK.", "success",
"downloaded", &feedback_error))
g_warning("%s", feedback_error->message);
Bastian-Krause marked this conversation as resolved.
Show resolved Hide resolved

g_mutex_unlock(&active_action->mutex);
return GINT_TO_POINTER(TRUE);
}
if (!feedback_progress(artifact->feedback_url, active_action->id, "File checksum OK.",
&error)) {
g_warning("%s", error->message);
Expand Down Expand Up @@ -1064,6 +1075,7 @@ static gboolean process_deployment(JsonNode *req_root, GError **error)

// handle deployment.maintenanceWindow (only available if maintenance window is defined)
maintenance_window = json_get_string(resp_root, "$.deployment.maintenanceWindow", NULL);
artifact->maintenance_window = g_strdup(maintenance_window);
maintenance_msg = maintenance_window
? g_strdup_printf(" (maintenance window is '%s')", maintenance_window)
: g_strdup("");
Expand Down Expand Up @@ -1486,6 +1498,7 @@ void artifact_free(Artifact *artifact)
g_free(artifact->download_url);
g_free(artifact->feedback_url);
g_free(artifact->sha1);
g_free(artifact->maintenance_window);
g_free(artifact);
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_download_only(hawkbit, config, assign_bundle):
assert exitcode == 0

status = hawkbit.get_action_status()
assert any(['download' in s['type'] for s in status])
assert status[0]['type'] == 'downloaded'

# check last status message
assert 'File checksum OK.' in status[0]['messages']