Rebooting only when a user asks

The state script docs mentions that

Tip: Since a power loss in ArtifactReboot_Enter will not be marked as a failure, this enables the user to stall the daemon in ArtifactReboot_Enter state forever, and thus an install will only be installed on a power-cycle of the device.

How do I do that? I created a script with the name ArtifactReboot_Enter_00 that has

#!/bin/sh
exit 21

in it. However, it reboots after a while with the logs:

2020-04-08 17:02:39 +0000 UTC info: Running Mender version 2.2.0
2020-04-08 17:02:39 +0000 UTC debug: handle update fetch state
2020-04-08 17:02:39 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:02:39 +0000 UTC debug: Received fetch update response &{200 OK 200 HTTP/1.1 1 1 map[Accept-Ranges:[bytes] Last-Modified:[Wed, 08 Apr 2020 17:00:45 GMT] Vary:[Origin] X-Amz-Request-Id:[1603E6E39D4C12A2] X-Content-Type-Options:[nosniff] Content-Type:[application/vnd.mender-artifact] Content-Security-Policy:[block-all-mixed-content] X-Xss-Protection:[1; mode=block] Server:[openresty/1.13.6.2] Strict-Transport-Security:[max-age=0; includeSubdomains; preload] Connection:[keep-alive] Content-Length:[727045632] Etag:["135d5c2c5ceb2e04a60f711dc166c3c9"] X-Frame-Options:[DENY] Date:[Wed, 08 Apr 2020 17:02:39 GMT]] 0xc000095a60 727045632 [] false false map[] 0xc000411000 0xc0000d2630}+
2020-04-08 17:02:39 +0000 UTC info: State transition: update-fetch [Download_Enter] -> update-store [Download_Enter]
2020-04-08 17:02:39 +0000 UTC debug: handle update install state
2020-04-08 17:02:39 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:02:39 +0000 UTC debug: Read data from device manifest file: device_type=qemux86_64
2020-04-08 17:02:39 +0000 UTC debug: Current manifest data: qemux86_64
2020-04-08 17:02:39 +0000 UTC info: no public key was provided for authenticating the artifact
2020-04-08 17:02:39 +0000 UTC debug: checking if device [qemux86_64] is on compatible device list: [qemux86_64]
2020-04-08 17:02:39 +0000 UTC debug: installer: processing script: ArtifactReboot_Enter_00
2020-04-08 17:02:39 +0000 UTC debug: installer: successfully read artifact [name: release-4; version: 3; compatible devices: [qemux86_64]]
2020-04-08 17:02:39 +0000 UTC debug: Active partition: /dev/sda2
2020-04-08 17:02:39 +0000 UTC debug: Detected inactive partition /dev/sda3, based on active partition /dev/sda2
2020-04-08 17:02:39 +0000 UTC info: opening device /dev/sda3 for writing
2020-04-08 17:02:39 +0000 UTC debug: Open block-device for installing update of size: 3245721600
2020-04-08 17:02:39 +0000 UTC debug: Device: /dev/sda3 is a ubi device: false
2020-04-08 17:02:39 +0000 UTC info: native sector size of block device /dev/sda3 is 512, we will write in chunks of 1048576
2020-04-08 17:02:39 +0000 UTC debug: Opening device: /dev/sda3 for writing with flag: 2
2020-04-08 17:06:31 +0000 UTC info: 0 bytes remaining to be written
2020-04-08 17:06:31 +0000 UTC info: The optimized block-device writer wrote a total of 3096 frames, where 2266 frames did need to be rewritten
2020-04-08 17:06:31 +0000 UTC info: Wrote 3245721600/3245721600 bytes to the inactive partition
2020-04-08 17:06:31 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:06:31 +0000 UTC info: State transition: update-store [Download_Enter] -> update-after-store [Download_Leave]
2020-04-08 17:06:31 +0000 UTC info: State transition: update-after-store [Download_Leave] -> update-install [ArtifactInstall]
2020-04-08 17:06:31 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:06:31 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:06:31 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:06:31 +0000 UTC debug: Inactive partition: /dev/sda3
2020-04-08 17:06:31 +0000 UTC debug: Marking inactive partition (/dev/sda3) as the new boot candidate.
2020-04-08 17:06:31 +0000 UTC info: Enabling partition with new image installed to be a boot candidate: 3
2020-04-08 17:06:31 +0000 UTC debug: Have U-Boot variable: mender_check_saveenv_canary=
2020-04-08 17:06:31 +0000 UTC debug: List of U-Boot variables:map[mender_check_saveenv_canary:]
2020-04-08 17:06:31 +0000 UTC debug: Marking inactive partition as a boot candidate successful.
2020-04-08 17:06:31 +0000 UTC info: State transition: update-install [ArtifactInstall] -> reboot [ArtifactReboot_Enter]
2020-04-08 17:06:31 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:06:31 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:06:31 +0000 UTC debug: start executing script: ArtifactReboot_Enter_00
2020-04-08 17:06:31 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:06:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:06:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:06:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:07:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:07:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:07:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:08:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:08:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:08:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:09:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:09:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:09:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:10:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:10:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:10:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:11:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:11:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:11:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:12:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:12:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:12:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:13:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:13:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:13:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:14:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:14:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:14:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:15:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:15:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:15:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:16:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:16:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:16:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:17:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:17:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:17:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:18:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:18:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:18:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:19:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:19:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:19:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:20:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:20:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:20:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:21:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:21:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:21:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:22:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:22:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:22:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:23:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:23:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:23:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:24:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:24:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:24:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:25:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:25:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:25:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:26:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:26:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:26:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:27:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:27:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:27:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:28:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:28:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:28:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:29:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:29:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:29:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:30:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:30:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:30:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:31:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:31:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:31:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:32:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:32:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:32:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:33:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:33:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:33:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:34:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:34:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:34:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:35:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:35:32 +0000 UTC info: statescript: ArtifactReboot_Enter_00 requested a retry
2020-04-08 17:35:32 +0000 UTC warning: No timeout interval set for the retry-scripts. Falling back to default: 1m0s
2020-04-08 17:36:32 +0000 UTC warning: No total time set for the retry-scripts' timeslot. Falling back to default: 30m0s
2020-04-08 17:36:32 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:36:32 +0000 UTC error: transient error: error calling enter script for (error) reboot state: error running enter state script(s) for ArtifactReboot_Enter state: statescript: retry time-limit exceeded exit status 21
2020-04-08 17:36:32 +0000 UTC info: State transition: reboot [ArtifactReboot_Enter] -> rollback [ArtifactRollback]
2020-04-08 17:36:32 +0000 UTC debug: transitioning to error state
2020-04-08 17:36:32 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:32 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:32 +0000 UTC info: performing rollback
2020-04-08 17:36:32 +0000 UTC debug: Have U-Boot variable: mender_check_saveenv_canary=
2020-04-08 17:36:32 +0000 UTC debug: List of U-Boot variables:map[mender_check_saveenv_canary:]
2020-04-08 17:36:32 +0000 UTC debug: Have U-Boot variable: upgrade_available=1
2020-04-08 17:36:32 +0000 UTC debug: List of U-Boot variables:map[upgrade_available:1]
2020-04-08 17:36:32 +0000 UTC debug: Inactive partition: /dev/sda3
2020-04-08 17:36:32 +0000 UTC debug: Marking inactive partition (/dev/sda3) as the new boot candidate.
2020-04-08 17:36:32 +0000 UTC info: setting partition for rollback: 3
2020-04-08 17:36:32 +0000 UTC debug: Have U-Boot variable: mender_check_saveenv_canary=
2020-04-08 17:36:32 +0000 UTC debug: List of U-Boot variables:map[mender_check_saveenv_canary:]
2020-04-08 17:36:32 +0000 UTC debug: Marking inactive partition as a boot candidate successful.
2020-04-08 17:36:32 +0000 UTC debug: will try to rollback reboot the device
2020-04-08 17:36:32 +0000 UTC info: State transition: rollback [ArtifactRollback] -> rollback-reboot [ArtifactRollbackReboot_Enter]
2020-04-08 17:36:32 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:32 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:32 +0000 UTC info: rebooting device(s) after rollback
2020-04-08 17:36:32 +0000 UTC info: Mender rebooting from inactive partition: /dev/sda2
2020-04-08 17:36:40 +0000 UTC info: Running Mender version 2.2.0
2020-04-08 17:36:40 +0000 UTC info: Update was interrupted in state: rollback-reboot
2020-04-08 17:36:40 +0000 UTC info: State transition: init [none] -> verify-rollback-reboot [ArtifactRollbackReboot_Leave]
2020-04-08 17:36:40 +0000 UTC debug: transitioning to error state
2020-04-08 17:36:40 +0000 UTC debug: Have U-Boot variable: mender_check_saveenv_canary=
2020-04-08 17:36:40 +0000 UTC debug: List of U-Boot variables:map[mender_check_saveenv_canary:]
2020-04-08 17:36:40 +0000 UTC debug: Have U-Boot variable: upgrade_available=0
2020-04-08 17:36:40 +0000 UTC debug: List of U-Boot variables:map[upgrade_available:0]
2020-04-08 17:36:40 +0000 UTC info: State transition: verify-rollback-reboot [ArtifactRollbackReboot_Leave] -> after-rollback-reboot [ArtifactRollbackReboot_Leave]
2020-04-08 17:36:40 +0000 UTC debug: handling state after rollback reboot
2020-04-08 17:36:40 +0000 UTC info: State transition: after-rollback-reboot [ArtifactRollbackReboot_Leave] -> update-error [ArtifactFailure]
2020-04-08 17:36:40 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:40 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:40 +0000 UTC debug: handle update error state
2020-04-08 17:36:40 +0000 UTC info: State transition: update-error [ArtifactFailure] -> cleanup [Error]
2020-04-08 17:36:40 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:40 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:40 +0000 UTC debug: Handling Cleanup state
2020-04-08 17:36:40 +0000 UTC info: State transition: cleanup [Error] -> update-status-report [none]
2020-04-08 17:36:40 +0000 UTC debug: statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds
2020-04-08 17:36:40 +0000 UTC debug: handle update status report state
2020-04-08 17:36:40 +0000 UTC debug: status reported, response 204 No Content
2020-04-08 17:36:40 +0000 UTC debug: attempting to upload deployment logs for failed update

I’d like to not tweak StateScriptRetryTimeoutSeconds for other scripts, but I will if that’s necessary.

Hi @lights0123,

As it is right now you would need to adjust StateScriptRetryTimeoutSeconds for it not to timeout. There is no special config just for the the ArtifactReboot_Enter state, which might have been nice to better support this use-case.

Sounds good. Another question: in this thread, I see that calling mender -check-update in daemon mode is supported. However, when I do so, I get the message:

ERRO[0000]: updateCheck: Failed to send 0 the mender process, pid:0  module=main

Any ideas? systemctl status mender-client says that it’s active and running.

What client version are you running?

Seems to me that this commit is missing

I’m running 2.2.0 runtime: go1.11.5, created by the latest commit of mender-convert. This rootfs was last updated today.

Ah, I do not know the full back-story of this issue but then it seems that this functionality is broken in the 2.2.0 client that comes packaged in deb