Skip to content

Commit 2e5c12d

Browse files
committed
client: reboot to perform rollback if deployment data are invalid
1 parent d13b01b commit 2e5c12d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

core/src/mender-client.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,15 +700,15 @@ mender_client_initialization_work_function(void) {
700700
if (MENDER_OK != (ret = mender_storage_get_deployment_data(&deployment_data))) {
701701
if (MENDER_NOT_FOUND != ret) {
702702
mender_log_error("Unable to get deployment data");
703-
goto END;
703+
goto REBOOT;
704704
}
705705
}
706706
if (NULL != deployment_data) {
707707
if (NULL == (mender_client_deployment_data = cJSON_Parse(deployment_data))) {
708-
mender_log_error("Unable to allocate memory");
708+
mender_log_error("Unable to parse deployment data");
709709
free(deployment_data);
710710
ret = MENDER_FAIL;
711-
goto END;
711+
goto REBOOT;
712712
}
713713
free(deployment_data);
714714
}
@@ -717,6 +717,18 @@ mender_client_initialization_work_function(void) {
717717

718718
END:
719719

720+
return ret;
721+
722+
REBOOT:
723+
724+
/* Delete pending deployment */
725+
mender_storage_delete_deployment_data();
726+
727+
/* Invoke restart callback, application is responsible to shutdown properly and restart the system */
728+
if (NULL != mender_client_callbacks.restart) {
729+
mender_client_callbacks.restart();
730+
}
731+
720732
return ret;
721733
}
722734

0 commit comments

Comments
 (0)