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

feat(docker-win): add main for windows #271

Open
wants to merge 3 commits into
base: feat/windows-support
Choose a base branch
from

Conversation

rajrohanyadav
Copy link
Contributor

  • This modifies the module to enable adding windows functionality.
  • Certain decisions made to minimise duplication.
  • Cgoups will only be supported for linux. Windows and darwin will use dockerAPI.

@rajrohanyadav rajrohanyadav marked this pull request as ready for review February 4, 2025 06:21
@rajrohanyadav rajrohanyadav requested a review from a team as a code owner February 4, 2025 06:21
src/util/util.go Show resolved Hide resolved
src/util/util_linux.go Show resolved Hide resolved
src/raw/cgroup.go Show resolved Hide resolved
src/util/util_all.go Show resolved Hide resolved
@rajrohanyadav rajrohanyadav requested review from rahulreddy15 and a team February 4, 2025 09:59
Copy link

@rahulreddy15 rahulreddy15 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

@sigilioso sigilioso left a comment

Choose a reason for hiding this comment

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

Overall LGTM 👍 I've left some comments regarding minor things.

I guess more stuff needs to be changed as part a follow-up PRs: compiling for windows and linux, updating the readme, ....

@@ -6,7 +6,7 @@ type ArgumentList struct {
args.DefaultArgumentList
HostRoot string `default:"" help:"If the integration is running from a container, the mounted folder pointing to the host root folder"`
Fargate bool `default:"false" help:"Enables fetching metrics from ECS Fargate. If enabled no metrics are collected from cgroups. Defaults to false"`
UseDockerAPI bool `default:"false" help:"Enables fetching metrics from Docker API. If enabled no metrics are collected from cgroups. This option is ignored if cgroupsV1 are detected"`
UseDockerAPI bool `default:"false" help:"Enables fetching metrics from Docker API. If enabled no metrics are collected from cgroups. This option is ignored if cgroupsV1 are detected or running on any OS other than linux"`
Copy link
Contributor

Choose a reason for hiding this comment

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

When cgroupsV1 is detected we set it to false and when running on any OS other than linux we set it to true. Is that right? I wonder if we could be clearer somehow 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attempted to improve it in 19d53c8
I believe we could default it to true for next releases, but not sure if that will be a breaking change 💭
Let's keep it this way for this release just to de-couple things, and I'll try to see if it can be defaulted to true for all.

Comment on lines 19 to 21
func UpdateDockerAPIArg(dockerAPIArg bool) bool {
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could improve the function name, the Update part suggest some modification and it is merely returning a value (even if it is used to modify the args right now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved the function name in 023d6cc
Hmm, I didn't want someone to make a mistake of reading args somewhere in the program and then finding that it's value is different from the main caller. So, I updated the arg globally to avoid such mistakes. WDYT 🤔

src/docker.go Outdated
Comment on lines 23 to 24
// we always use the docker API for OSes other than Linux
args.UseDockerAPI = util.UpdateDockerAPIArg(args.UseDockerAPI)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also avoid modifying the args if possible. Maybe something like:

useDockerAPI := util.shouldUseDockerAPI(args.UseDockerAPI)

We could also move the comment above to the OS specific implementation of the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment in 023d6cc
For args, the same reason as I added above. I could pass across this var, but just think someone (most probably me 3 months later 😄 ) might make a mistake with different global and local values.

@rajrohanyadav
Copy link
Contributor Author

I guess more stuff needs to be changed as part a follow-up PRs: compiling for windows and linux, updating the readme, ....

Yes, more PRs will be there. Just wanted to help the reviewers with smaller PRs :)

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