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

Improves and fixes jailer #96

Merged
merged 3 commits into from
Jun 26, 2019
Merged

Improves and fixes jailer #96

merged 3 commits into from
Jun 26, 2019

Conversation

jeromegn
Copy link
Contributor

Description of changes:

  • Adds configurable Stdin on jailer
  • Proper handling of the logs and metrics fifos
  • Adds machine.PID() to get the process ID and possibly gather metrics on the process

@jeromegn
Copy link
Contributor Author

Some tests are failing, any pointers would help. I assume it's all tests that were calling setupLogging and expecting it to create fifos.

@samuelkarp
Copy link
Contributor

Some tests are failing, any pointers would help. I assume it's all tests that were calling setupLogging and expecting it to create fifos.

I reran the CI job and there are a few things that are showing as failing:

--- FAIL: TestJail (0.00s)
    jailer_test.go:162: did not find link files handler

This looks like it's caused by your change here; the AppendAfter function expects the first argument to represent a handler already in the chain.

--- FAIL: TestStartVMMOnce (0.02s)
    machine_test.go:408: startVMM failed: Failed to create log fifo: no such file or directory
--- FAIL: TestLogFiles (0.00s)
    machine_test.go:709: unexpected error: Failed to create log fifo: no such file or directory

These two look like failures to find the log fifo, possibly because the LinkFilesHandler isn't being run.

--- FAIL: TestJailerMicroVMExecution (0.09s)
    machine_test.go:246: Failed to start VMM: link testdata/firecracker.log /tmp/jailer-test760018090/firecracker/b/root/firecracker.log: invalid cross-device link

On our CI host, /tmp is a bind-mount hard-links fail between /tmp and the directory where tests are being run.

*** Test killed with quit: ran too long (10m0s).

I don't know offhand what's taking too long to run.

jailer.go Show resolved Hide resolved
handlers.go Show resolved Hide resolved
@xibz
Copy link
Contributor

xibz commented May 21, 2019

Can you also add an os.Stat in the TestJailerMicroVM test to ensure that the fifos are actually linked in the Jailer's chroot?

In addition, an update to the CHANGELOG.md under the unreleased section with a description of this change?

@jeromegn
Copy link
Contributor Author

Might be a little while until I look at this again.

It works for us right now so I'm just using it as-is.

@jeromegn
Copy link
Contributor Author

Anything missing here, since @xibz's pushes?

Copy link
Contributor

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

Hi @jeromegn, my apologies for the delay! I have a few small questions about some of the changes.

jailer.go Show resolved Hide resolved
machine.go Outdated
@@ -152,6 +152,14 @@ func (m *Machine) Logger() *log.Entry {
return m.logger.WithField("subsystem", userAgent)
}

// PID returns the machine's process ID
func (m *Machine) PID() (int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be missing something, but I don't see this function getting called anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I wasn't sure about this function, but I assumed @jeromegn was using it for something, so I didn't touch it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using it, but it could be part of a separate PR. I need to get at the PID for the process for the scheduling software I'm using.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jeromegn Thanks! Can we move this to a separate PR?

jailer.go Show resolved Hide resolved
machine_test.go Show resolved Hide resolved
Copy link
Contributor

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

Code looks good, but it'd be good to fix up the commit messages with the format we expect as well.

  • <= 50 character subject line
  • Additional content in body, if needed
  • Body wrapped at 72 characters
  • Signed-off-by lines
  • Squash the fixup! commits

@xibz
Copy link
Contributor

xibz commented Jun 26, 2019

@samuelkarp - Did you mean wrapped body at 72 instead of 50?

@samuelkarp
Copy link
Contributor

@xibz oops, yes 😅

jeromegn and others added 3 commits June 26, 2019 14:56
This fix includes proper handling of fifos as before the SDK was not
adding the fifo files to the correct root path during jailing. We now
have a new handler, CreateLogFilesHandler, that will now create the
fifos in the appropriate location and ensure that the fifos have correct
permissions.

Signed-off-by: xibz <impactbchang@gmail.com>
Prior to this fix the SDK would use os.Stdin if no stdin was provided in
the jailer config. This would cause shell sessions to break and should
only include stdin if it was provided in the jailer config.

Signed-off-by: xibz <impactbchang@gmail.com>
The machine configuration fifo paths originally pointed to somewhere on
the host. However, the fifo paths should be pointing to the chroot of
the jailer. This fix addresses that and renames the error that is
returned from the jailer handler as it was way too specific.

Signed-off-by: xibz <impactbchang@gmail.com>
@xibz xibz merged commit b0a25b1 into firecracker-microvm:master Jun 26, 2019
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.

None yet

3 participants