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

chore: fail deployment on spontaneous reboot #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danielskinstad
Copy link
Collaborator

See motivation for this change:

A spontaneous reboot / power loss is detected when the stored state is something other than MENDER_UPDATE_STATE_VERIFY_REBOOT or MENDER_UPDATE_STATE_ROLLBACK_VERIFY_REBOOT.

Ticket: MEN-8197

See motivation for this change:
- https://docs.mender.io/artifact-creation/state-scripts#power-loss

A spontaneous reboot / power loss is detected when the stored state is
something other than `MENDER_UPDATE_STATE_VERIFY_REBOOT` or
`MENDER_UPDATE_STATE_ROLLBACK_VERIFY_REBOOT`.

Ticket: MEN-8197

Signed-off-by: Daniel Skinstad Drabitzius <[email protected]>
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.

Generally I don't think it's a good idea to use a negative condition in one place (not one of these two states) and then add handling of the case based on a positive condition (is one of these states). I'd prefer using the same condition in both places -- client initialization and the work function. And I'd probably even do it before the while-switch block.

spontaneous_reboot = false;
ret = MENDER_FAIL;
NEXT_STATE;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about the REBOOT state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The docs say Power loss is allowed to happen within any Reboot state, since it may be indistinguishable from a normal reboot

/* Check for a spontaneous reboot */
mender_update_state_t update_state;
if (MENDER_OK == (ret = mender_deployment_data_get_state(mender_client_deployment_data, &update_state))) {
if ((MENDER_UPDATE_STATE_VERIFY_REBOOT != update_state) && (MENDER_UPDATE_STATE_ROLLBACK_VERIFY_REBOOT != update_state)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

DOWNLOAD state should be ok, right?

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.

2 participants