State script returning exit status 1 leads to retry loop instead of abort

pseyfert
Wed, 15 Feb 2023 15:27:55 +0000
General Discussions

Hi,

I’m working on a state script (Download_Enter in my case) that shall (depending on stuff) return 0, 1, or 21, depending on if i want the upgrade to go on, abort, or delay until later (following the docs here).

I mostly experimented with a standalone upgrade (running mender install ./local_file.mender) with the desired behaviour. However, when triggering an upgrade from hosted.mender.io, the code branch that returns 1 seems to lead to a retry-loop. I have set the number of tries to 1 in the webui so that’s not where the retries come from. To simplify debugging, I actually reduced the state script to

#!/bin/bash

exit 1

and I tested

/etc/mender/scripts/Download_Enter_00_MyTest
echo $?

prints 1.

In the journal (journalctl -f -t mender) i see the following looping over (minor editting applied)

Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=error msg="transient error: error calling enter script for (error) update-fetch state: error running enter state script(s) for Download_Enter state: statescript: error executing 'Download_Enter_00_MyTest': 1 : exit status 1"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=error msg="transient error: error calling enter script for (error) update-fetch state: error running enter state script(s) for Download_Enter state: statescript: error executing 'Download_Enter_00_MyTest': 1 : exit status 1"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="State transition: update-fetch [Download_Enter] -> error [Error]"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="State transition: update-fetch [Download_Enter] -> error [Error]"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="Handling error state, current error: transient error: error calling enter script for (error) update-fetch state: error running enter state script(s) for Download_Enter state: statescript: error executing 'Download_Enter_00_MyTest': 1 : exit status 1"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="State transition: error [Error] -> idle [Idle]"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="Handling error state, current error: transient error: error calling enter script for (error) update-fetch state: error running enter state script(s) for Download_Enter state: statescript: error executing 'Download_Enter_00_MyTest': 1 : exit status 1"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="State transition: error [Error] -> idle [Idle]"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="State transition: idle [Idle] -> check-wait [Idle]"
Feb 15 16:19:59 <hostname> mender[5275]: time="2023-02-15T16:19:59+01:00" level=info msg="State transition: idle [Idle] -> check-wait [Idle]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: check-wait [Idle] -> inventory-update [Sync]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: check-wait [Idle] -> inventory-update [Sync]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: inventory-update [Sync] -> check-wait [Idle]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: inventory-update [Sync] -> check-wait [Idle]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="Validating the Update Info: https://s3.amazonaws.com/hosted-mender-artifacts/... [name: <artifactname>; devices: [<device-type>]]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: update-check [Sync] -> update-fetch [Download_Enter]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="Validating the Update Info: https://s3.amazonaws.com/hosted-mender-artifacts/... [name: <artifactname>; devices: [<device-type>]]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="State transition: update-check [Sync] -> update-fetch [Download_Enter]"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="Executing script: Download_Enter_00_MyTest"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=info msg="Executing script: Download_Enter_00_MyTest"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=error msg="transient error: error calling enter script for (error) update-fetch state: error running enter state script(s) for Download_Enter state: statescript: error executing 'Download_Enter_00_MyTest': 1 : exit status 1"
Feb 15 16:20:04 <hostname> mender[5275]: time="2023-02-15T16:20:04+01:00" level=error msg="transient error: error calling enter script for (error) update-fetch state: error running enter state script(s) for Download_Enter state: statescript: error executing 'Download_Enter_00_MyTest': 1 : exit status 1"

My understanding from the docs “If a script returns 0 Mender proceeds, but if it returns 1 the update is aborted and rolled back.” was that 1 should abort the upgrade and not keep trying (in fact, I can confirm that the logs are different when I return 21). Am I missing / overlooking something how to abort a hosted.mender.io-triggered upgrade from a Download_Enter script?

8 posts - 3 participants