Skip to content

Commit

Permalink
Don't restart iotedged when config.yaml isn't ready (#1278)
Browse files Browse the repository at this point in the history
On Linux (systemd) when iotedge is installed, the daemon is configured to always restart on failure. Its config.yaml file needs to be configured by the user after installation, so as soon as it starts the first time it will go into a fail/restart loop until it exceeds the start rate limit and enters a cooldown period (a failed state where manual intervention is required). This change maps a specific exit code for this condition (specifically, failure when the connection string in config.yaml hasn't been changed from its boilerplate value), and instructs systemd to prevent restart for this exit code.

This change will help with automated tests, which sometimes trip the rate limiting threshold and aren't equipped to do manual intervention.
  • Loading branch information
damonbarry authored May 31, 2019
1 parent 257a5b7 commit 1570c2c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions edgelet/contrib/systemd/debian/iotedge.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ KillMode=process
TimeoutStartSec=600
TimeoutStopSec=40
Restart=on-failure
RestartPreventExitStatus=153
User=iotedge
Group=iotedge

Expand Down
1 change: 1 addition & 0 deletions edgelet/contrib/systemd/iotedge.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ KillMode=process
TimeoutStartSec=600
TimeoutStopSec=40
Restart=on-failure
RestartPreventExitStatus=153
User=iotedge
Group=iotedge

Expand Down
3 changes: 2 additions & 1 deletion edgelet/iotedged/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ impl From<&ErrorKind> for i32 {
// Using 150 as the starting base for custom IoT edge error codes so as to avoid
// collisions with -
// 1. The standard error codes defined by the BSD ecosystem
// (https://www.freebsd.org/cgCould not get module i/man.cgi?query=sysexits&apropos=0&sektion=0&manpath=FreeBSD+11.2-stable&arch=default&format=html)
// (https://www.freebsd.org/cgi/man.cgi?query=sysexits&apropos=0&sektion=0&manpath=FreeBSD+11.2-stable&arch=default&format=html)
// that is recommended by the Rust docs
// (https://rust-lang-nursery.github.io/cli-wg/in-depth/exit-code.html)
// 2. Bash scripting exit codes with special meanings
// (http://www.tldp.org/LDP/abs/html/exitcodes.html)
ErrorKind::Initialize(InitializeErrorReason::InvalidDeviceConfig) => 150,
ErrorKind::Initialize(InitializeErrorReason::InvalidHubConfig) => 151,
ErrorKind::InvalidSignedToken => 152,
ErrorKind::Initialize(InitializeErrorReason::NotConfigured) => 153,
_ => 1,
}
}
Expand Down

0 comments on commit 1570c2c

Please sign in to comment.