[Unit]
Description=Monitoring Service
[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill dd-agent
ExecStartPre=-/usr/bin/docker rm dd-agent
ExecStartPre=/usr/bin/docker pull datadog/docker-dd-agent
ExecStart=/usr/bin/bash -c \
"/usr/bin/docker run --privileged --name dd-agent -h `hostname` \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /proc/mounts:/host/proc/mounts:ro \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
-e API_KEY=`etcdctl get /ddapikey` \
datadog/docker-dd-agent"
[X-Fleet]Global=true
ExecStartPre=/usr/bin/etcdctl set /ddapikey MYKEY
Sometimes it starts on all three nodes. But, usually, it fails on at least one node. Here is the log on the one it failed on:
core@tt0 ~ $ systemctl status -l datadog
● datadog.service - Monitoring Service
Loaded: loaded (/etc/systemd/system/datadog.service; linked-runtime; vendor preset: disabled)
Drop-In: /etc/systemd/system/datadog.service.d
└─50-ddapikey-config.conf
Active: failed (Result: exit-code) since Mon 2015-03-09 13:31:52 UTC; 10min ago
Process: 1800 ExecStart=/usr/bin/bash -c /usr/bin/docker run --privileged --name dd-agent -h `hostname` -v /var/run/docker.sock:/var/run/docker.sock -v /proc/mounts:/host/proc/mounts:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=`etcdctl get /ddapikey` datadog/docker-dd-agent (code=exited, status=1/FAILURE)
Process: 1793 ExecStartPre=/usr/bin/etcdctl set /ddapikey MYKEY (code=exited, status=0/SUCCESS)
Process: 1683 ExecStartPre=/usr/bin/docker pull datadog/docker-dd-agent (code=exited, status=0/SUCCESS)
Process: 1673 ExecStartPre=/usr/bin/docker rm dd-agent (code=exited, status=1/FAILURE)
Process: 1665 ExecStartPre=/usr/bin/docker kill dd-agent (code=exited, status=1/FAILURE)
Main PID: 1800 (code=exited, status=1/FAILURE)
Mar 09 13:31:51 tt0 docker[1683]: 7bc3216dd09e: Download complete
Mar 09 13:31:51 tt0 docker[1683]: 7bc3216dd09e: Download complete
Mar 09 13:31:51 tt0 docker[1683]: Status: Downloaded newer image for datadog/docker-dd-agent:latest
Mar 09 13:31:51 tt0 etcdctl[1793]: ac578ef8dc567125c0717a4d503c3342
Mar 09 13:31:51 tt0 systemd[1]: Started Monitoring Service.
Mar 09 13:31:52 tt0 bash[1800]: Error: 100: Key not found (/ddapikey) [826]
Mar 09 13:31:52 tt0 bash[1800]: You must set API_KEY environment variable to run the Datadog Agent container
Mar 09 13:31:52 tt0 systemd[1]: datadog.service: main process exited, code=exited, status=1/FAILURE
Mar 09 13:31:52 tt0 systemd[1]: Unit datadog.service entered failed state.Mar 09 13:31:52 tt0 systemd[1]: datadog.service failed.
So I go to that node and systemctl stop, kill, and start it. Which brings it up.
Obviously the place to put a super secret api key is not in the start scripts for that service. That aside, I made an assumption that ExecStartPre script happens before ExecStart, the indication with the process ID is that the assertion is true. The order of the logs seems to imply that the opposite happens sometimes.
My read from the documentation for systemd is that ExecStartPre are executed before ExecStart, serially. Is this true?
What is the best practice for picking up these sorts of things? Create a service which fetches the information from a secure source, and make this service dependent on that one?
-g
--
You received this message because you are subscribed to the Google Groups "CoreOS User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coreos-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to coreos-user+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to coreos-user...@googlegroups.com.
--help, -h show help
--consistent send request to the leader, thereby guranteeing that any earlier writes will be seen by the read