From 0c6c53fc7dc4e12bd6ba5351e03751d75512a102 Mon Sep 17 00:00:00 2001 From: henrygd Date: Sun, 11 Jan 2026 16:07:24 -0500 Subject: [PATCH] fix isSystemdAvailable in containers and update alpine to 3.23 --- agent/systemd.go | 15 +++++++++++---- internal/dockerfile_agent_alpine | 2 +- internal/dockerfile_agent_intel | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/agent/systemd.go b/agent/systemd.go index 8801e3f4..43351298 100644 --- a/agent/systemd.go +++ b/agent/systemd.go @@ -29,10 +29,17 @@ type systemdManager struct { patterns []string } -// isSystemdAvailable checks if systemd is used on the system to avoid unnecessary connection attempts. +// isSystemdAvailable checks if systemd is used on the system to avoid unnecessary connection attempts (#1548) func isSystemdAvailable() bool { - if _, err := os.Stat("/run/systemd/system"); err == nil { - return true + paths := []string{ + "/run/systemd/system", + "/run/dbus/system_bus_socket", + "/var/run/dbus/system_bus_socket", + } + for _, path := range paths { + if _, err := os.Stat(path); err == nil { + return true + } } if data, err := os.ReadFile("/proc/1/comm"); err == nil { return strings.TrimSpace(string(data)) == "systemd" @@ -48,7 +55,7 @@ func newSystemdManager() (*systemdManager, error) { // Check if systemd is available on the system before attempting connection if !isSystemdAvailable() { - slog.Debug("Systemd not available on this system") + slog.Debug("Systemd not available") return nil, nil } diff --git a/internal/dockerfile_agent_alpine b/internal/dockerfile_agent_alpine index 277a0078..87444c8f 100644 --- a/internal/dockerfile_agent_alpine +++ b/internal/dockerfile_agent_alpine @@ -17,7 +17,7 @@ RUN rm -rf /tmp/* # -------------------------- # Final image: default scratch-based agent # -------------------------- -FROM alpine:3.22 +FROM alpine:3.23 COPY --from=builder /agent /agent RUN apk add --no-cache smartmontools diff --git a/internal/dockerfile_agent_intel b/internal/dockerfile_agent_intel index 702c27b6..a6166cca 100644 --- a/internal/dockerfile_agent_intel +++ b/internal/dockerfile_agent_intel @@ -16,7 +16,7 @@ RUN CGO_ENABLED=0 GOGC=75 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "- # Final image # Note: must cap_add: [CAP_PERFMON] and mount /dev/dri/ as volume # -------------------------- -FROM alpine:3.22 +FROM alpine:3.23 COPY --from=builder /agent /agent