Skip to content

Commit

Permalink
hawkbit-client: Return proper status on download-only
Browse files Browse the repository at this point in the history
SUCCESS would translate from DDI state to action state "Downloaded",
which is exactly what hawkbit expects in case of download-only
deployemnt.

Ref #159

Signed-off-by: Vyacheslav Yurkov <[email protected]>
  • Loading branch information
UVV-gh committed Jul 12, 2023
1 parent d7af1af commit ad332dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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;
if (!feedback(artifact->feedback_url, active_action->id, "File checksum OK.", "success",
"downloaded", &feedback_error))
g_warning("%s", feedback_error->message);

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

0 comments on commit ad332dc

Please sign in to comment.