-
Notifications
You must be signed in to change notification settings - Fork 1.2k
runtime-rs: Label system journal log with kata #11641
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
Conversation
This PR mainly based on Choi's patch, Let's move it forward together. |
Hey Steve @stevenhorsman , I am working on labeling kata log based on the patchset shared by Choi @BbolroC PTAL. It's mainly to address the related issues in the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems reasonable. Let me pull it into the test PR and undo that log redirects to try and test it in practice
// Use the .new() method to build a child logger which inherits all existing | ||
// key-value pairs from its parent and supplements them with additional ones. | ||
// This is the idiomatic way. | ||
base_logger.new(o!("SYSLOG_IDENTIFIER" => "kata")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional thought: Should we extract kata
as the syslog identifier to be a constant at the top of the file for more visibility (not that I'm expecting we would need to update it in future though)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,sound reasonable. I will update it later
In https://github.com/kata-containers/kata-containers/actions/runs/16644091629/job/47104336991 I ran this code and the result was:
and this test has:
which suggests the logging to the kata syslog id is working 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and the testing seemed to work ok
Thx Steve @stevenhorsman for this report😄. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
@@ -14,7 +14,7 @@ pub(crate) fn set_logger(path: &str, sid: &str, is_debug: bool) -> Result<slog_a | |||
//it's better to open the log pipe file with read & write option, | |||
//otherwise, once the containerd reboot and closed the read endpoint, | |||
//kata shim would write the log pipe with broken pipe error. | |||
let fifo = std::fs::OpenOptions::new() | |||
let _fifo = std::fs::OpenOptions::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we keep this around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update the code without it.
Route kata-shim logs directly to systemd-journald under 'kata' identifier. This refactoring enables `kata-shim` logs to be properly attributed to 'kata' in systemd-journald, instead of inheriting the 'containerd' identifier. Previously, `kata-shim` logs were challenging to filter and debug as they appeared under the `containerd.service` unit. This commit resolves this by: 1. Introducing a `LogDestination` enum to explicitly define logging targets (File or Journal). 2. Modifying logger creation to set `SYSLOG_IDENTIFIER=kata` when logging to Journald. 3. Ensuring type safety and correct ownership handling for different logging backends. This significantly enhances the observability and debuggability of Kata Containers, making it easier to monitor and troubleshoot Kata-specific events. Fixes: kata-containers#11590 Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com> Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @Apokleos !
Route kata-shim logs directly to systemd-journald under 'kata' identifier
This refactoring enables
kata-shim
logs to be properly attributed to 'kata' in systemd-journald, instead of inheriting the 'containerd' identifier.Previously,
kata-shim
logs were challenging to filter and debug as they appeared under thecontainerd.service
unit.This commit resolves this by:
LogDestination
enum to explicitly define logging targets (File or Journal).SYSLOG_IDENTIFIER=kata
when logging to Journald.This significantly enhances the observability and debuggability of Kata Containers, making it easier to monitor and troubleshoot Kata-specific events.
Fixes: #11590
Signed-off-by: Hyounggyu Choi Hyounggyu.Choi@ibm.com
Signed-off-by: Alex Lyn alex.lyn@antgroup.com