[Bug 274194] sysutils/loki: New rc.d file for promtail

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 07 Oct 2023 06:56:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274194

--- Comment #4 from Eren Türkay <turkay.eren@gmail.com> ---
Created attachment 245475
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=245475&action=edit
first attempt to add rc.d script for promtail

Hello,

The patch is ready and tested but I've came across a few issues. 2 of them are
port related (I used portfmt and portlint), and the last one is
configuration/daemon behavior.



SHA2 Mismatch (hashicorp-consul-v1.5.1_GH0.tar.gz)
=============
I got checksum error on this file. I do not think it should change but I had to
build the package with `NO_CHECKSUM=yes` to proceed. When I manually download
the file, the hash in `distinfo` does not match the one I download. Since I do
not know what's going on with the hash, I did not include it in the patch.

```
$ wget
'https://codeload.github.com/hashicorp/consul/tar.gz/v1.5.1?dummy=/hashicorp-consul-v1.5.1_GH0.tar.gz'
-O hashicorp-consul-v1.5.1_GH0.tar.gz
$ sha256sum hashicorp-consul-v1.5.1_GH0.tar.gz
7d9a318ca5fe3c5f35adb950750e92dff45a67d5fe37d447f173b4f0f99c095f 
hashicorp-consul-v1.5.1_GH0.tar.gz
```


Portlint Messages
=================
I generated the patch using `make makepatch` but I still get a warning. I know
portlint can give some false positives but I still wanted to let you know:


```
WARN: Makefile: possible use of absolute pathname "/seed".
WARN: Makefile: possible use of absolute pathname "/var/db/${PORTNAME}".
WARN: Makefile: possible use of absolute pathname "/var/db/promtail".
WARN:
/usr/home/ec2-user/ports/sysutils/loki/files/patch-cmd-loki-loki-local-config.yaml:
patch was not generated using ``make makepatch''.  It is recommended to use
``make makepatch'' when you need to [re-]generate a patch to ensure proper
patch format.
WARN:
/usr/home/ec2-user/ports/sysutils/loki/files/patch-promtail-local-config.yaml:
patch was not generated using ``make makepatch''.  It is recommended to use
``make makepatch'' when you need to [re-]generate a patch to ensure proper
patch format.
0 fatal errors and 5 warnings found.
```


Promtail Stop Behavior
=====================
This one is interesting. Since we include upstream default configuration and I
do not have loki server installed, promtail has a long retry configuration.
Once it reads the file, it cannot find the loki server and starts retrying.
When you want to stop the daemon, you wait on `waiting for PIDs` message.

I waited for a couple of minutes at first, the daemon did not stop and I
interrupted it to stop it again. I thought it was a problem with the rc.d
script but it turns out it's related with retry configuration.

The defaults are described here:
https://grafana.com/docs/loki/latest/send-data/promtail/configuration/#clients

min_period: 500ms
max_period: 5m
max_retries: 10

This means you need to wait at least 5 minutes before promtail finishes
retries. I have confirmed it by lowering those values and seeing that
max_retries need to be reached before stopping the server. So, if for any
reason promtail cannot reach loki and retries, it should finish first. The sad
thing is that you do not see how many retries are left in the log file, you
just see `will retry` message and it can be confusing.

As someone worked on this package, I know this information but daemon stop
behavior can be hard to spot. Do you think it's appropriate to add a note
somewhere and refer to the official documentation?

Regards,
Eren

-- 
You are receiving this mail because:
You are the assignee for the bug.