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

all: add AIX provider #77

Merged
merged 2 commits into from
Jul 20, 2020
Merged

all: add AIX provider #77

merged 2 commits into from
Jul 20, 2020

Conversation

Helflym
Copy link
Contributor

@Helflym Helflym commented Jan 27, 2020

Add a implementation without CGO for AIX.
Host information are retrieved using AIX commands (uname, oslevel)
Process information are retrieved by /proc folder.

A CGO implementation could be added to more accurate syscalls and libraries
(getprocs, libperfstat, etc). But github.com/elastic/gosigar provides such
things.

A few features are still missing:

  • Host CPU usage since boot time: there is no easy way to retrieve it.
  • Process' environment

providers/aix/machineid_aix.go Show resolved Hide resolved
providers/aix/kernel_aix.go Outdated Show resolved Hide resolved
providers/aix/host_aix.go Outdated Show resolved Hide resolved
providers/aix/host_aix.go Show resolved Hide resolved
providers/aix/defs_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/process_aix.go Outdated Show resolved Hide resolved
providers/aix/os_aix.go Outdated Show resolved Hide resolved
providers/aix/os_aix.go Show resolved Hide resolved
Copy link
Contributor

@fearful-symmetry fearful-symmetry left a comment

Choose a reason for hiding this comment

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

Due to the security restrictions on Metricbeat, which this is used by, We can't exec to other binaries, so this won't work:

out, err := exec.Command("/usr/bin/svmon", "-G").Output()

@Helflym
Copy link
Contributor Author

Helflym commented Mar 2, 2020

Due to the security restrictions on Metricbeat, which this is used by, We can't exec to other binaries, so this won't work:

out, err := exec.Command("/usr/bin/svmon", "-G").Output()

Isn't seccomp only available on Linux ? I don't think there is any way to achieve a similar behavior on AIX and I'm sure we aren't the only one. Does Windows, Macos and BSD have something similar ?

Anyway, I can reworked the whole patch, in order to avoid exec syscalls. But it's using cgo, which I was trying to avoid here, and external C libraries. I've done something similar for elastic/gosigar (I haven't created the PR yet). Do you prefer to have something like that ?

@andrewkroh
Copy link
Member

Despite not having a seccomp on AIX, I still think a native approach would be better. Usually the native approach is less CPU intensive and less prone to breakage over time (or at least we are quicker to detect the breakage when an API changes vs when the output of a command changes).

The biggest concern I have about adding an AIX provider is that we have no way to test it. So we have very limited ability to maintain it.

For my own education, what version of AIX does Go support? Is it AIX 7.2 on power8? And is this done with GOOS=aix GOARCH=ppc64?

@Helflym
Copy link
Contributor Author

Helflym commented Mar 3, 2020

Despite not having a seccomp on AIX, I still think a native approach would be better. Usually the native approach is less CPU intensive and less prone to breakage over time (or at least we are quicker to detect the breakage when an API changes vs when the output of a command changes).

Actually, AIX has a real strict compatibility behavior and therefore commands' outputs won't change. However, I understand your point of view and I'll move to a CGO version as soon as I can.

The biggest concern I have about adding an AIX provider is that we have no way to test it. So we have very limited ability to maintain it.

Sadly, that's the case for every Go packages. My opinion is that if anything ever go wrong, the AIX community will be able to send PRs to fix it.
For this package, as it's included inside metricbeat and that we are planning to deliver it for almost every version, we will be able to find any bugs quite quickly.

For my own education, what version of AIX does Go support? Is it AIX 7.2 on power8? And is this done with GOOS=aix GOARCH=ppc64?

Yes, the Go toolchain is available only for AIX 7.2 on Power8 and Power9 (but I haven't try on P9). As you said, we are using GOOS=aix and GOARCH=ppc64.
It might work on previous AIX versions with gccgo, but I haven't tested that yet.

providers/aix/kernel_aix.go Show resolved Hide resolved
providers/aix/doc.go Outdated Show resolved Hide resolved
providers/aix/defs_aix.go Outdated Show resolved Hide resolved
providers/aix/kernel_aix.go Show resolved Hide resolved
providers/aix/doc.go Outdated Show resolved Hide resolved
providers/aix/defs_aix.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fearful-symmetry fearful-symmetry left a comment

Choose a reason for hiding this comment

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

We're making progress! We still need some standardization of the names to make the linters happy, and tests.

providers/aix/boottime_aix.go Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/defs_aix.go Outdated Show resolved Hide resolved
providers/aix/host_aix.go Show resolved Hide resolved
Copy link
Contributor

@fearful-symmetry fearful-symmetry left a comment

Choose a reason for hiding this comment

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

We still need to make the linter happy and deal with some standardization issues.

providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
providers/aix/boottime_aix.go.rej Outdated Show resolved Hide resolved
providers/aix/defs_aix.go.rej Outdated Show resolved Hide resolved
providers/aix/doc.go Outdated Show resolved Hide resolved
providers/aix/host_aix.go Show resolved Hide resolved
providers/aix/host_aix.go Show resolved Hide resolved
providers/aix/os_aix.go Outdated Show resolved Hide resolved
providers/aix/process_aix.go.rej Outdated Show resolved Hide resolved
providers/aix/os_aix.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fearful-symmetry fearful-symmetry left a comment

Choose a reason for hiding this comment

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

Almost done from my perspective. I'd like @andrewkroh to sign off on the PR too. We can save testing for later, but we're gonna eventually need to set up environments in AIX.

Not sure what @andrewkroh thinks, but I'd like to avoid cutting a release until we have an AIX environment setup so we can at least do manual testing.

providers/aix/process_aix.go Show resolved Hide resolved
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

I made a suggestion for one simple test that can be executed outside of AIX. If there are any other unit tests you can add that would be great. Even if we can't execute them today on CI they will still be helpful to anyone that's maintaining the AIX code.

Overall it LGTM. Can you please

  • update the README.md with a column for AIX/ppc64.
  • run the tests and paste the output into a comment

providers/aix/boottime_aix.go Outdated Show resolved Hide resolved
@Helflym
Copy link
Contributor Author

Helflym commented Apr 17, 2020

The two other unit tests which can be made are (*process) User() and (*process) CPUTime() as they are the only ones dealing with /proc files. Tell me if you wish me to add them but I don't think it will be worth it to just check these two functions while all other dealing with processes aren't.

For the test output, you wish to have the result of "go test -v" that's it ? Even for all processes running on my local machines, or just a sample will be enough ?

@fearful-symmetry
Copy link
Contributor

Hey @Helflym sorry for the long silence. We've been waiting until Elastic has access to a proper AIX environment before we go any further. That took...longer than anticipated.

A few things:

  • The tests are failing because in system_test.go you marked Environment as false, but it appears to be implemented anyways.
  • I don't think it's worth it right now to add additional unit tests, since Elastic people can now test manually, and because it's unlikely we'll have AIX CI set up in the short-medium term.

@Helflym
Copy link
Contributor Author

Helflym commented Jul 10, 2020

Yeah don't worry. I was warned by the IBM team for that.

The tests are failing because in system_test.go you marked Environment as false, but it appears to be implemented anyways.
Because it's set as True in my environment. I don't know how I missed that one...

@fearful-symmetry
Copy link
Contributor

@Helflym thanks. Hopefully close to getting this merged.

Sorry to change my mind, would it be possible to get these tests after all?

The two other unit tests which can be made are (*process) User() and (*process) CPUTime() as they are the only ones dealing with /proc files.

Assuming everything is green, we should be good to merge after that.

@Helflym
Copy link
Contributor Author

Helflym commented Jul 15, 2020

Sorry to change my mind, would it be possible to get these tests after all?

The two other unit tests which can be made are (*process) User() and (*process) CPUTime() as they are the only ones dealing with /proc files.

Actually, it's a bit more complicated than I thought. I either need to change the way I'm retrieving "/proc" information or I need to check the test process but it seems to unstable for me.
Do you really wish these tests or can they be added to a TODO ? I'm a bit overwhelmed by other stuff right now, so I would be glad if I can add them later.

@fearful-symmetry
Copy link
Contributor

@Helflym We can add them them later if it takes too much effort. I'd like to get this in a state where it can be merged.

@Helflym Helflym force-pushed the master branch 3 times, most recently from a8b20c1 to e729806 Compare July 17, 2020 08:47
Clément Chigot and others added 2 commits July 17, 2020 10:48
Add a implementation with CGO for AIX.

Process information are retrieved by /proc folder or with libperfstat,
getprocs syscalls.
@fearful-symmetry fearful-symmetry merged commit 77fcdd7 into elastic:master Jul 20, 2020
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.

4 participants