sensu-backend init keeps looping
maxadamo opened this issue · 4 comments
Description of problem
I upgraded from 6.3.0 top 6.4.0 and sensu backend tries to run init every time:
Exec[sensu-backend init]/returns: executed successfully (corrective)
Command used and debugging output
If I try to execute the code from the following unless
statement, it throws 0
instead of 3
:
exec { 'sensu-backend init':
path => '/usr/bin:/bin:/usr/sbin:/sbin',
command => "sensu-backend init --config-file ${sensu::etc_dir}/backend.yml",
environment => [
'SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin',
"SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=${sensu::password}",
],
returns => [0, 3],
# sensu-backend init will exit with code 3 if already run
# If exit code is 3, do not need to run sensu-backend init again
# If exit is not 3, run sensu-backend init
unless => "sensu-backend init --config-file ${sensu::etc_dir}/backend.yml ; [ \$? -eq 3 ] && exit 0 || exit 1",
require => Sensu_api_validator['sensu'],
before => [
Sensu_user['admin'],
Sensuctl_configure['puppet'],
],
}
Platform and version information
- Your OS: Ubuntu 18.04
- Your Ruby version:
- Your version of Puppet: Puppet OpenSource 7.8
- Your version of Sensu: 6.4.0
- Your version of this module: 5.8.0
I'm also seeing this-- I'm wondering if it's a behaviour change in the client itself.
What does the exit code from this produce on a system already initialized and running Sensu Go 6.4.0?
export SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin
export SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=<put your admin password here>
sensu-backend init
echo $?
The Puppet code expects the exit code to be 3 if the backend is already initialized. I looked at code a little and looks like sensu/sensu-go#4287 may have changed the behavior so that the already initialized error is not returned and therefore this is never called: https://github.com/sensu/sensu-go/blob/f127173bda159139757bf6bae2a6af83a7a91394/cmd/sensu-backend/main.go#L30-L32
Looks like Sensu Go has a fix merged: sensu/sensu-go#4346