opentelemetry-collector-releases icon indicating copy to clipboard operation
opentelemetry-collector-releases copied to clipboard

User names inconsistent between core and contrib

Open mowies opened this issue 1 year ago • 5 comments

I just noticed that the user names for the linux services for otelcol and otelcol-contrib are not consistently named.

distro username
otelcol otel
otelcol-contrib otelcol-contrib

mowies avatar Jul 23 '24 13:07 mowies

Привет, @mowies! Я здесь, чтобы помочь вам решить проблему. Я бот, который может помочь вам исправить ошибки, ответить на вопросы и стать участником.

To standardize the usernames for the otelcol and otelcol-contrib services across different distributions, you can ensure that both services use the same User and Group settings in their respective service files. For example, if you decide to use otel as the username, the service files should look like this:

For otelcol:

[Unit]
Description=OpenTelemetry Collector
After=network.target

[Service]
EnvironmentFile=/etc/otelcol/otelcol.conf
ExecStart=/usr/bin/otelcol $OTELCOL_OPTIONS
KillMode=mixed
Restart=on-failure
Type=simple
User=otel
Group=otel

[Install]
WantedBy=multi-user.target

For otelcol-contrib:

[Unit]
Description=OpenTelemetry Collector Contrib
After=network.target

[Service]
EnvironmentFile=/etc/otelcol-contrib/otelcol-contrib.conf
ExecStart=/usr/bin/otelcol-contrib $OTELCOL_CONTRIB_OPTIONS
KillMode=mixed
Restart=on-failure
Type=simple
User=otel
Group=otel

[Install]
WantedBy=multi-user.target

Additionally, in the Dockerfile for otelcol-contrib, you can set the user to otel by using the USER directive with a specific UID. For example:

FROM alpine:3.19 as certs
RUN apk --update add ca-certificates

FROM scratch

ARG USER_UID=10001
USER ${USER_UID}

COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --chmod=755 otelcol-contrib /otelcol-contrib
COPY config.yaml /etc/otelcol-contrib/config.yaml
ENTRYPOINT ["/otelcol-contrib"]
CMD ["--config", "/etc/otelcol-contrib/config.yaml"]
EXPOSE 4317 55678 55679

By setting User=otel and Group=otel in both service files and ensuring the Dockerfile uses a consistent UID, you can standardize the usernames across different distributions [1][2].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Jul 23 '24 13:07 dosubot[bot]

I believe this is a bug :-)

jpkrohling avatar Jul 23 '24 14:07 jpkrohling

Changing the username sounds like a potentially breaking change to me. Do I need to keep anything in mind while fixing this?

mowies avatar Jul 24 '24 06:07 mowies

I can't think of anything important other than taking care of the files created by the previous user, like the persistent sending queue files.

jpkrohling avatar Jul 24 '24 09:07 jpkrohling

i guess this is a duplicate of https://github.com/open-telemetry/opentelemetry-collector-releases/issues/417

mowies avatar Jul 29 '24 12:07 mowies