premium-minds / spotdrain

GNU Lesser General Public License v3.0
0 stars 0 forks source link

systemd journal log spam #6

Open froque opened 1 week ago

froque commented 1 week ago

If this service is deployed on an instance that is not spot, the systemd journal is being spammed with:

admin@i-0a7a558938a65a3ba:~$ sudo journalctl --since '2024-07-01 14:00:00' -t spotdrain 
Jul 01 14:00:22 i-0a7a558938a65a3ba spotdrain[826367]: 2024/07/01 14:00:22 WARN: Datadog env not found. Event will not have env tag
Jul 01 14:00:22 i-0a7a558938a65a3ba spotdrain[826367]: 2024/07/01 14:00:22 This is not a spot instance. Spotdrain will not run
Jul 01 14:00:22 i-0a7a558938a65a3ba spotdrain[826367]: 2024/07/01 14:00:22 Exiting ...
Jul 01 14:01:07 i-0a7a558938a65a3ba spotdrain[826625]: 2024/07/01 14:01:07 WARN: Datadog env not found. Event will not have env tag
Jul 01 14:01:07 i-0a7a558938a65a3ba spotdrain[826625]: 2024/07/01 14:01:07 This is not a spot instance. Spotdrain will not run
Jul 01 14:01:07 i-0a7a558938a65a3ba spotdrain[826625]: 2024/07/01 14:01:07 Exiting ...
Jul 01 14:01:52 i-0a7a558938a65a3ba spotdrain[826886]: 2024/07/01 14:01:52 WARN: Datadog env not found. Event will not have env tag
Jul 01 14:01:52 i-0a7a558938a65a3ba spotdrain[826886]: 2024/07/01 14:01:52 This is not a spot instance. Spotdrain will not run
Jul 01 14:01:52 i-0a7a558938a65a3ba spotdrain[826886]: 2024/07/01 14:01:52 Exiting ...
Jul 01 14:02:37 i-0a7a558938a65a3ba spotdrain[827163]: 2024/07/01 14:02:37 WARN: Datadog env not found. Event will not have env tag
Jul 01 14:02:37 i-0a7a558938a65a3ba spotdrain[827163]: 2024/07/01 14:02:37 This is not a spot instance. Spotdrain will not run
Jul 01 14:02:37 i-0a7a558938a65a3ba spotdrain[827163]: 2024/07/01 14:02:37 Exiting ...
Jul 01 14:03:23 i-0a7a558938a65a3ba spotdrain[827415]: 2024/07/01 14:03:23 WARN: Datadog env not found. Event will not have env tag
Jul 01 14:03:23 i-0a7a558938a65a3ba spotdrain[827415]: 2024/07/01 14:03:23 This is not a spot instance. Spotdrain will not run
Jul 01 14:03:23 i-0a7a558938a65a3ba spotdrain[827415]: 2024/07/01 14:03:23 Exiting ...
froque commented 1 week ago

proposal for workaround

ExecCondition=/bin/sh -c 'test $(curl -s --fail http://169.254.169.254/latest/meta-data/instance-life-cycle) = "spot"'