Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(log): ingore error log when journal is disable #1955

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

BlackHole1
Copy link
Contributor

@BlackHole1 BlackHole1 commented Oct 14, 2024

There is no systemd and journal in our distribution, and when using ignition, many warning logs are printed. The changes in this PR will check if there is a journal in the current distribution, and if not, it will not pass the logs to the journal.

img_v3_02fl_4ae5cd52-92cc-4c5a-a110-a6d3e432c6dg

Notes: The distro Alpine has no journal. Add conditional to avoid failure due to logging method not being available.

@BlackHole1
Copy link
Contributor Author

Friendly ping @jlebon

Copy link
Collaborator

@prestist prestist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! sorry for the delay and thank you for adding this change, and 100% that makes sense. Could you make two small changes.

  • include in your commit message the distribution that you are referring to
    i.e somthing like: "the distro x has no journal. Add conditional to avoid failure due to logging method not being available. "
  • add a item to the release notes under changes sub-header

@BlackHole1
Copy link
Contributor Author

@prestist Done

@prestist
Copy link
Collaborator

@BlackHole1 sorry I still am seeing some spelling/grammar issues with your commit message wdyt about this?

exec/engine: log to journal only when available

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 [email protected]

Also can you please add an comment to the release notes? talking about this under changes for the unreleased version.

@BlackHole1 BlackHole1 force-pushed the ignore-journal-log branch 3 times, most recently from 6b57636 to f98f1ef Compare October 24, 2024 02:47
@BlackHole1
Copy link
Contributor Author

@prestist Thank you for your review suggestions!

@prestist
Copy link
Collaborator

@BlackHole1 I took a closer look at the code and the symptoms, have you tested this code change? I suspect you will still get that warning.

@BlackHole1
Copy link
Contributor Author

BlackHole1 commented Oct 30, 2024

@prestist Sorry I'm late. I just did some testing locally. The issue you're worried about won't happen.

package main

import (
	"fmt"

	"github.com/coreos/go-systemd/v22/journal"
)

func main() {
	fmt.Println("====> test journal.Enabled()")
	for i := 0; i < 10; i++ {
		fmt.Println(journal.Enabled())
	}

	fmt.Println("====> test journal.Send()")

	for i := 0; i < 10; i++ {
		if err := journal.Send("MESSAGE=Hello, World!", journal.PriInfo, nil); err != nil {
			fmt.Println("Send Error: ", err)
		}
	}
}

CleanShot 2024-10-30 at 16 27 53@2x

@BlackHole1
Copy link
Contributor Author

Friendly ping @prestist :)

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, but looks sane to me

docs/release-notes.md Outdated Show resolved Hide resolved
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 <[email protected]>
@BlackHole1
Copy link
Contributor Author

@jlebon Done

@jlebon jlebon enabled auto-merge November 7, 2024 16:22
@jlebon jlebon merged commit 7226d77 into coreos:main Nov 7, 2024
9 checks passed
@BlackHole1 BlackHole1 deleted the ignore-journal-log branch November 7, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants