hashicorp/terraform-aws-consul

systemd reload not working

Opened this issue · 0 comments

Describe the bug
The "reload" operation set up for systemd by run_consul does not work
https://github.com/hashicorp/terraform-aws-consul/blob/master/modules/run-consul/run-consul#L376

As set up, the reload operation called here cannot succeed unless it has access to the full set of environment variables including a valid acl token. If any items are missing there will be an error.

Log file entries

Running systemctl restart consul.service fails with the following entries:

Jun 27 19:35:42 ip-10-142-24-123 systemd[1]: Reloading "HashiCorp Consul - A service mesh solution".
Jun 27 19:35:47 ip-10-142-24-123 consul[2511144]: Error reloading: Put "http://127.0.0.1:8500/v1/agent/reload": dial tcp 127.0.0.1:8500: connect: connection refused
Jun 27 19:35:47 ip-10-142-24-123 systemd[1]: consul.service: Control process exited, code=exited, status=1/FAILURE
Jun 27 19:35:47 ip-10-142-24-123 systemd[1]: Reload failed for "HashiCorp Consul - A service mesh solution".

Suggested fix
Systemd can send a signal to the process which causes it to reload
The unit config looks like this (with escaping so it pastes directly into run-consul L376)

ExecReload=/bin/kill -HUP \$MAINPID

First question was - has this been considered already? It works fine for me but maybe there was a reason for using the consul binary directly?