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

Fixed Consistent Log Levelling #1490

Closed
wants to merge 0 commits into from

Conversation

PalmPalm7
Copy link

@PalmPalm7 PalmPalm7 commented Jun 4, 2024

Edit: Have finished consistent log leveling issue.

Made changes to exisisting codebase with structured logs from format logs. Github issue ref.

Added logging kepler with klog section on dev/README.md, see here.

Copy link

github-actions bot commented Jun 4, 2024

🤖 SeineSailor

Here is a concise summary of the pull request changes:

Summary: This pull request primarily focuses on improving logging and error handling in the codebase. The key modifications include:

  1. Logging updates: Replacing klog.Infof with klog.InfoS and updating log verbosity levels to provide more context for logged messages, enhancing structured logging.
  2. Error handling: Introducing error handling for resolving container and VM IDs, making the code more robust.
  3. Debugging flags: Adding flags for log debugging, allowing for more granular control over logging.

Impact: These changes improve the overall logging experience, providing more informative messages without affecting the external interface or behavior of the code.

Observations:

  • The changes are mostly related to logging and error handling, indicating a focus on improving the codebase's reliability and maintainability.
  • The introduction of InfoS and ErrorS functions in the golangci-lint configuration suggests a move towards more structured and informative logging.
  • The lack of changes in pkg/collector/stats/utils.go might indicate that this file was not affected by the logging updates or error handling changes.

Suggestions for improvement:

  • Consider adding more context or comments to explain the reasoning behind the logging updates and error handling changes, making it easier for future maintainers to understand the code.
  • Verify that the added debugging flags do not introduce any performance or security concerns.
  • Review the golangci-lint configuration to ensure it aligns with the project's coding standards and best practices.

@PalmPalm7 PalmPalm7 force-pushed the main branch 2 times, most recently from d8849d7 to 14c8f70 Compare June 20, 2024 12:31
@PalmPalm7 PalmPalm7 marked this pull request as ready for review June 20, 2024 12:33
@PalmPalm7 PalmPalm7 changed the title "place-holder commit/PR" Fixed Consistant Log Levelling Jun 20, 2024
@PalmPalm7 PalmPalm7 changed the title Fixed Consistant Log Levelling Fixed Consistent Log Levelling Jun 20, 2024
@PalmPalm7 PalmPalm7 force-pushed the main branch 2 times, most recently from 1400dc5 to 77d4005 Compare June 20, 2024 14:41
Copy link
Collaborator

@dave-tucker dave-tucker left a comment

Choose a reason for hiding this comment

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

A few things in the rebase to fix up.
I've left some comments for small changes.
I think it's mostly when we're using InfoS (not preceeded by V(n)) with err as one of the values that we'd be better off using ErrorS.
That and some small changes to grammar or messages.

Comment on lines 95 to 102
func finalizing() {
stack := "exit stack: \n" + string(debug.Stack())
klog.InfoS(stack)
exitCode := 10
klog.Infoln(finishingMsg)
klog.FlushAndExit(klog.ExitFlushTimeout, exitCode)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This can go. It was removed in #1503

klog.Infoln(finishingMsg)
klog.FlushAndExit(klog.ExitFlushTimeout, exitCode)
}

func main() {
start := time.Now()
klog.InitFlags(nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This registers the flags - you can see this from running kepler -help

// for log debugging issues
flag.Set("logtostderr", "false")
flag.Set("alsologtostderr", "true")
flag.Set("log_dir", "/root/kepler/kepler_prime/kepler_debug/logs1.txt")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's safe to assume this directory exists everywhere.
I'd probably remove it.

func main() {
start := time.Now()
klog.InitFlags(nil)

// for log debugging issues
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this setting defaults that are different to what klog provides?

flag.Set("alsologtostderr", "true")
flag.Set("log_dir", "/root/kepler/kepler_prime/kepler_debug/logs1.txt")
flag.Set("v", "2")

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tested that the log level can still be correctly overridden?

@@ -0,0 +1,59 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this file was also deleted

@@ -66,3 +66,15 @@ func (c *ContainerStats) String() string {
c.ContainerID,
) + c.Stats.String()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

As was this function

}

// cgroup metric are deprecated and will be removed later
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was also removed in a recent PR

@@ -104,7 +110,7 @@ func GetNodeName() string {
func getCPUArch() string {
arch, err := getCPUArchitecture()
if err == nil {
klog.V(3).Infof("Current CPU architecture: %s", arch)
klog.V(3).InfoS("Current CPU architecture:", "arch", arch)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
klog.V(3).InfoS("Current CPU architecture:", "arch", arch)
klog.V(3).InfoS("Discovered CPU architecture", "arch", arch)

Comment on lines 149 to 155
klog.V(5).InfoS("Configuration value", "ENABLE_EBPF_CGROUPID", EnabledEBPFCgroupID)
klog.V(5).InfoS("Configuration value", "ENABLE_GPU", EnabledGPU)
klog.V(5).InfoS("Configuration value", "ENABLE_QAT", EnabledQAT)
klog.V(5).InfoS("Configuration value", "ENABLE_PROCESS_METRICS", EnableProcessStats)
klog.V(5).InfoS("Configuration value", "EXPOSE_HW_COUNTER_METRICS", ExposeHardwareCounterMetrics)
klog.V(5).InfoS("Configuration value", "EXPOSE_CGROUP_METRICS", ExposeCgroupMetrics)
klog.V(5).InfoS("Configuration value", "EXPOSE_IRQ_COUNTER_METRICS", ExposeIRQCounterMetrics)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can make this all one line:

Suggested change
klog.V(5).InfoS("Configuration value", "ENABLE_EBPF_CGROUPID", EnabledEBPFCgroupID)
klog.V(5).InfoS("Configuration value", "ENABLE_GPU", EnabledGPU)
klog.V(5).InfoS("Configuration value", "ENABLE_QAT", EnabledQAT)
klog.V(5).InfoS("Configuration value", "ENABLE_PROCESS_METRICS", EnableProcessStats)
klog.V(5).InfoS("Configuration value", "EXPOSE_HW_COUNTER_METRICS", ExposeHardwareCounterMetrics)
klog.V(5).InfoS("Configuration value", "EXPOSE_CGROUP_METRICS", ExposeCgroupMetrics)
klog.V(5).InfoS("Configuration value", "EXPOSE_IRQ_COUNTER_METRICS", ExposeIRQCounterMetrics)
klog.V(5).InfoS("Configuration values", "ENABLE_EBPF_CGROUPID", EnabledEBPFCgroupID, "ENABLE_GPU", EnabledGPU, "ENABLE_QAT", EnabledQAT,"ENABLE_PROCESS_METRICS", EnableProcessStats, "EXPOSE_HW_COUNTER_METRICS", ExposeHardwareCounterMetrics, "EXPOSE_CGROUP_METRICS", ExposeCgroupMetrics, "EXPOSE_IRQ_COUNTER_METRICS", ExposeIRQCounterMetrics)

@dave-tucker
Copy link
Collaborator

@PalmPalm7 when you've fixed the issues with the rebase, you might want to run make format to ensure all your Go code is properly formatted, and make golint also to catch any issues.

@PalmPalm7
Copy link
Author

@PalmPalm7 when you've fixed the issues with the rebase, you might want to run make format to ensure all your Go code is properly formatted, and make golint also to catch any issues.

Thank you for the Review Dave, I'll make changes to ensure they are properly formatted.

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.

2 participants