From 6b5763685b481616bfd6556201ccd988ebf7780d Mon Sep 17 00:00:00 2001 From: Kevin Cui Date: Thu, 24 Oct 2024 10:42:07 +0800 Subject: [PATCH] exec/engine: log to journal only when available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alpine Linux does not include systemd’s journal, which causes Ignition to emit warnings when attempting to log. This PR introduces a check to determine if the journal is available on the current distribution, and skips logging to the journal when it is not present. Signed-off-by: Kevin Cui --- docs/release-notes.md | 1 + internal/exec/engine.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 6120d77b9..3f5d368ef 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -22,6 +22,7 @@ nav_order: 9 - Fix network race when phoning home on Equinix Metal - Fix Akamai Ignition base64 decoding on padded payloads - Fix Makefile GOARCH for loongarch64 ([#1942](https://github.com/coreos/ignition/pull/1942)) +- Fix Alpine distro print journal not beging available warn ([#1955](https://github.com/coreos/ignition/pull/1955)) ## Ignition 2.19.0 (2024-06-05) diff --git a/internal/exec/engine.go b/internal/exec/engine.go index 54c8438aa..3f3125cf6 100644 --- a/internal/exec/engine.go +++ b/internal/exec/engine.go @@ -179,7 +179,7 @@ func (e *Engine) acquireConfig(stageName string) (cfg types.Config, err error) { cfg, err = e.acquireProviderConfig() // if we've successfully fetched and cached the configs, log about them - if err == nil { + if err == nil && journal.Enabled() { for _, cfgInfo := range e.State.FetchedConfigs { if logerr := logStructuredJournalEntry(cfgInfo); logerr != nil { e.Logger.Info("failed to log systemd journal entry: %v", logerr)