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

[fix]: add test case with darwin OS #1856

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SamYuan1990
Copy link
Collaborator

@SamYuan1990 SamYuan1990 commented Nov 21, 2024

add test case for config package.
remove unused function.
refactor function name to keep same naming convention.
refactor function behavior to same with function name.

Copy link

github-actions bot commented Nov 21, 2024

🤖 SeineSailor

Here is a concise summary of the pull request changes:

Summary:

This pull request primarily focuses on adding support for Darwin (MacOS) by removing platform-specific build restrictions, introducing test cases, and refactoring functions for consistency. The key modifications include:

  1. Removing //go:build !darwin comments to allow building on Darwin.
  2. Adding test cases for Darwin OS, including new files for handling eBPF programs.
  3. Updating functions related to enabling/disabling metrics, refactoring function names and behavior for consistency, and removing unused functions.
  4. Introducing new structs and functions for managing perf events and CPU cores.

Impact:

These changes may affect the external interface or behavior of the code, particularly:

  • Building on Darwin might result in changes to the external interface or behavior, depending on platform-specific functionality.
  • The updated functions for enabling/disabling metrics might impact other parts of the codebase that rely on the previous behavior.
  • Thorough testing on Darwin is essential to ensure compatibility and avoid unexpected behavior.

Suggestions:

  • Ensure comprehensive testing on Darwin to validate the changes and identify any potential issues.
  • Review the updated functions for enabling/disabling metrics to ensure they do not break existing functionality.
  • Consider adding documentation or comments to explain the changes and their implications for future maintainers.

@@ -454,15 +454,6 @@ func isCGroupV2(c Client) bool {
return !os.IsNotExist(err)
}

// Get cgroup version, return 1 or 2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this function is no longer used.

@@ -340,7 +340,7 @@ func SetEnabledIdlePower(enabled bool) {
// SetEnabledGPU enables the exposure of gpu metrics
func SetEnabledGPU(enabled bool) {
// set to true if any config source set it to true
instance.Kepler.EnabledGPU = enabled || instance.Kepler.EnabledGPU
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if the original instance.Kepler.EnabledGPU is true, which seems the function will not set the GPU enable from true to false.

Comment on lines +1 to +2
//go:build darwin
// +build darwin
Copy link
Collaborator

@sthaha sthaha Nov 24, 2024

Choose a reason for hiding this comment

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

Kepler won't run on osx, so IMHO, we shouldn't spend time on it. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

well, just because I am a mac user.
as a mac user, when I notice/make some nit fix.
I want to test those locally.
so, I made some build tag on files to make it happen.
any other suggestions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am completely fine with supporting darwin as long as we don't block it in CI as OSX isn't a supported platform.
I also feel it is best to focus on linux as the platform kepler support and hence all development on OSX is expected to use linux box (lima may work well)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, I agree currently darwin is not major platform to run kepler.
so, @sthaha , can we make an agreement as following:

kepler currently focus on linux platform.
for other platforms, to make kepler is easy for anyone contributes from any platform, we are welcome any benefits(PRs) for kepler including parts as compilable on other platform.
before the specific platform is supported, we just running CI on linux as PR merge standard and official support.

as instance, this PR, increasing test coverage on config package(benefits), with parts as compilable on darwin.

@@ -152,7 +152,7 @@ func main() {
platform.InitPowerImpl()
defer platform.StopPower()

if config.EnabledGPU() {
if config.IsEnabledGPU() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want to rename this, could you please rename it as IsGPUEnabled() ?

@@ -111,7 +114,7 @@ func (e *exporter) attach() error {
return fmt.Errorf("error attaching sched_switch tracepoint: %v", err)
}

if config.ExposeIRQCounterMetrics() {
if config.IsExposeIRQCounterMetrics() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

My preference is to leave it as is ..
IsExposeIRQCounterMetrics does not seem right. If we have to use Is for bool functions, I think the better option is IsIRQCounterMetricsExposed just like an English sentence.

@@ -142,7 +145,7 @@ func (e *exporter) attach() error {
}

// Return early if hardware counters are not enabled
if !config.ExposeHardwareCounterMetrics() {
if !config.IsExposeHardwareCounterMetrics() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, lets not change it.
config.ExposeHwCounterMetrics() reads better (proper English) than config.IsExposeHardwareCounterMetrics

@SamYuan1990
Copy link
Collaborator Author

markdownlint-cli2-rules-docker...........................................Failed
- hook id: markdownlint-cli2-rules-docker
- exit code: 1
Unable to find image 'davidanson/markdownlint-cli2-rules:latest' locally

ref https://github.com/sustainable-computing-io/kepler/actions/runs/12005981954/job/33464291051#step:4:75
@maryamtahhan could you please check the lint hook works or we need update the link hook?

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@SamYuan1990
Copy link
Collaborator Author

I think our commit msg check can't support Co-authored-by, as I added two commits from @maryamtahhan as suggestion change, as the suggestion LGTM.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@SamYuan1990
Copy link
Collaborator Author

@maryamtahhan , sorry, for short, I use force push to overwrite the approval for change suggestion, as webiny/action-conventional-commits#17

@SamYuan1990
Copy link
Collaborator Author

@rootfs , @sthaha , @vprashar2929 please help review this PR, if it looks good, let's merge it.

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.

5 participants