Skip to content

Commit

Permalink
client: reboot to perform rollback if deployment data are invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
joelguittet committed Aug 3, 2024
1 parent d13b01b commit 2e5c12d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions core/src/mender-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,15 @@ mender_client_initialization_work_function(void) {
if (MENDER_OK != (ret = mender_storage_get_deployment_data(&deployment_data))) {
if (MENDER_NOT_FOUND != ret) {
mender_log_error("Unable to get deployment data");
goto END;
goto REBOOT;
}
}
if (NULL != deployment_data) {
if (NULL == (mender_client_deployment_data = cJSON_Parse(deployment_data))) {
mender_log_error("Unable to allocate memory");
mender_log_error("Unable to parse deployment data");
free(deployment_data);
ret = MENDER_FAIL;
goto END;
goto REBOOT;
}
free(deployment_data);
}
Expand All @@ -717,6 +717,18 @@ mender_client_initialization_work_function(void) {

END:

return ret;

REBOOT:

/* Delete pending deployment */
mender_storage_delete_deployment_data();

/* Invoke restart callback, application is responsible to shutdown properly and restart the system */
if (NULL != mender_client_callbacks.restart) {
mender_client_callbacks.restart();
}

return ret;
}

Expand Down

0 comments on commit 2e5c12d

Please sign in to comment.