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

avoidFileSystem() needs to handle an alternate rootfs #141

Open
fearful-symmetry opened this issue Apr 12, 2024 · 0 comments
Open

avoidFileSystem() needs to handle an alternate rootfs #141

fearful-symmetry opened this issue Apr 12, 2024 · 0 comments
Labels
Team:Elastic-Agent Label for the Agent team

Comments

@fearful-symmetry
Copy link
Contributor

Right now, avoidFileSystem() in filesystem.go doesn't really have any understanding of an alternate hostfs set via a resolver:

devFileInfo, err := os.Stat(fs.Device)
if err != nil {
	debugf("error stating filesystem: %s", err)
}

It should use the resolver for the os.Stat call. However, there's some added complexity here, as in my experience, not all users will mount the entirety of / at /hostfs, which means we'll need some kind of check where if hostfs.IsSet() && err == ENOENT then we print a special error message or something.

@fearful-symmetry fearful-symmetry changed the title avoidFileSystem() needs to handle a alternate rootfs better avoidFileSystem() needs to handle a alternate rootfs Apr 12, 2024
@fearful-symmetry fearful-symmetry changed the title avoidFileSystem() needs to handle a alternate rootfs avoidFileSystem() needs to handle an alternate rootfs Apr 12, 2024
fearful-symmetry added a commit that referenced this issue Apr 18, 2024
…tainer (#140)

## What does this PR do?
Closes elastic/beats#38241

This adds a lightweight test framework that runs a set of system tests
under a container with the goal of monitoring the host system. The goal
with these tests is to catch the numerous edge cases that happen when
the system metrics function from a `/hostfs` path inside a container.

The tests have a fairly large matrix of configurations, as we need to
test both a wide variety of container permission settings, as well as
differences in how linux distros will configure cgroups.

The framework here was designed with the goal of being relatively
idiomatic; you can just run the framework with `go test` as you would
normally.

You can run the tests yourself with `go test -v ./tests`

As you may have noticed, there's a non-zero amount of TODO statements
here, since these tests were built to aggravate a bunch of existing
bugs, so certain parts of the tests will remain un-implemented until
those bugs are fixed.

## Why is it important?

See elastic/beats#38241, we really need test
for this particular case.

## List of bugs that are responsible for TODO statements in the tests:

- #141
- #135
- #139
- #132
- elastic/go-sysinfo#12

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added an entry in `CHANGELOG.md`
@pierrehilbert pierrehilbert added the Team:Elastic-Agent Label for the Agent team label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

No branches or pull requests

2 participants