alloy icon indicating copy to clipboard operation
alloy copied to clipboard

Debian buster package does not play systemctl daemon-reload after installation

Open nervo opened this issue 2 years ago • 4 comments

I've tested with current release 0.30.1-1. Here is a simple test scenario:

# Start debian buster docker systemd container
docker run --rm -ti --name grafana-agent-buster --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns host jrei/systemd-debian:buster

# In an another terminal, shell on it
docker exec -ti grafana-agent-buster bash

# Install grafana agent
apt update && apt install -y wget gnupg
wget -q https://apt.grafana.com/gpg.key -O- | apt-key add -
echo "deb https://apt.grafana.com stable main" > /etc/apt/sources.list.d/grafana.list
apt update && apt install -y grafana-agent

# Now let's check service status
systemctl status grafana-agent
> Unit grafana-agent.service could not be found.

# Ok let's reload...
systemctl daemon-reload
# And now \o/
systemctl status grafana-agent
> * grafana-agent.service - Monitoring system and forwarder
>    Loaded: loaded (/usr/lib/systemd/system/grafana-agent.service; disabled; vendor preset: enabled)
>    Active: inactive (dead)
>      Docs: https://grafana.com/docs/agent/latest/

I've also tested it on debian bullseye, but this time grafana-agent service is well detected:

docker run --rm -ti --name grafana-agent-bullseye --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns host jrei/systemd-debian:bullseye
docker exec -ti grafana-agent-bullseye bash
...
...
systemctl status grafana-agent
> * grafana-agent.service - Monitoring system and forwarder
>    Loaded: loaded (/usr/lib/systemd/system/grafana-agent.service; disabled; vendor preset: enabled)
>    Active: inactive (dead)
>      Docs: https://grafana.com/docs/agent/latest/

I suppose it's related to how debian package tools automatically handle service found in deb packages, and differences between buster and bullseye versions. Anyway, i also see that it's a common practice to force daemon-reload in postinst scripts, just like - for instance - hashicorp consul: https://github.com/hashicorp/consul/blob/main/.release/linux/postinstall

nervo avatar Dec 26 '22 12:12 nervo

Hmm, it looks like we're supposed to reload it, but only if RESTART_ON_UPGRADE is set.

@jdbaldry initially contributed the system packages; @jdbaldry do you remember why the RESTART_ON_UPGRADE check was added?

rfratto avatar Jan 04 '23 16:01 rfratto

My understanding is that is is useful to have RESTART_ON_UPGRADE as a safety mechanism to prevent unintended restarts of stateful services by configuration management tools or otherwise.

However, this should only be considered for upgrades and it makes sense to me that the service should start automatically on install so introducing the logic to do that seems reasonable.

jdbaldry avatar Jan 05 '23 09:01 jdbaldry

Hi there :wave:

On April 9, 2024, Grafana Labs announced Grafana Alloy, the spirital successor to Grafana Agent and the final form of Grafana Agent flow mode. As a result, Grafana Agent has been deprecated and will only be receiving bug and security fixes until its end-of-life around November 1, 2025.

To make things easier for maintainers, we're in the process of migrating all issues tagged variant/flow to the Grafana Alloy repository to have a single home for tracking issues. This issue is likely something we'll want to address in both Grafana Alloy and Grafana Agent, so just because it's being moved doesn't mean we won't address the issue in Grafana Agent :)

rfratto avatar Apr 11 '24 20:04 rfratto

We just run in the same issue while upgrading alloy from 1.2.0 to 1.3.0. Weirdly, half of our server fleet just updated correctly, the other half did not.

As you can see here: image

Skaronator avatar Aug 21 '24 13:08 Skaronator