Skip to content

Commit 0917f7f

Browse files
committed
Updating jailer to be compatible with v0.16.0
Signed-off-by: xibz <[email protected]>
1 parent 15c8087 commit 0917f7f

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

.buildkite/pipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ steps:
4545
- label: ':hammer: root tests'
4646
commands:
4747
- 'ln -s /var/lib/fc-ci/vmlinux.bin testdata/vmlinux'
48-
- 'cp /usr/local/bin/firecracker-v0.15.0 testdata/firecracker'
49-
- 'cp /usr/local/bin/jailer-v0.15.0 testdata/jailer'
48+
- 'cp /usr/local/bin/firecracker-v0.16.0 testdata/firecracker'
49+
- 'cp /usr/local/bin/jailer-v0.16.0 testdata/jailer'
5050
- "sudo FC_TEST_TAP=fc-root-tap${BUILDKITE_BUILD_NUMBER} make test EXTRAGOARGS='-v -count=1'"
5151
agents:
5252
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# [ Unreleased ]
22

3-
* Fixes bug where default socketpath would always be used when not using jailer (#84)
3+
* Fixes bug where context was not being used at all during startVM (#86)
4+
* Updates the jailer's socket path to point to the unix socket in the jailer's workspace (#86)
5+
* Fixes bug where default socketpath would always be used when not using jailer (#84).
46

57
# 0.15.1
68

jailer.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ type JailerConfig struct {
9494
Stdout io.Writer
9595
// Stderr specifies the IO writer for STDERR to use when spawning the jailer.
9696
Stderr io.Writer
97+
// Stdin specifies the IO reader for STDIN to use when spawning the jailer.
98+
Stdin io.Reader
9799
}
98100

99101
// JailerCommandBuilder will build a jailer command. This can be used to
@@ -288,14 +290,14 @@ func (b JailerCommandBuilder) Build(ctx context.Context) *exec.Cmd {
288290
// Jail will set up proper handlers and remove configuration validation due to
289291
// stating of files
290292
func jail(ctx context.Context, m *Machine, cfg *Config) error {
291-
rootfs := ""
293+
jailerWorkspaceDir := ""
292294
if len(cfg.JailerCfg.ChrootBaseDir) > 0 {
293-
rootfs = filepath.Join(cfg.JailerCfg.ChrootBaseDir, "firecracker", cfg.JailerCfg.ID)
295+
jailerWorkspaceDir = filepath.Join(cfg.JailerCfg.ChrootBaseDir, "firecracker", cfg.JailerCfg.ID, rootfsFolderName)
294296
} else {
295-
rootfs = filepath.Join(defaultJailerPath, cfg.JailerCfg.ID)
297+
jailerWorkspaceDir = filepath.Join(defaultJailerPath, cfg.JailerCfg.ID, rootfsFolderName)
296298
}
297299

298-
cfg.SocketPath = filepath.Join(rootfs, "api.socket")
300+
cfg.SocketPath = filepath.Join(jailerWorkspaceDir, "api.socket")
299301

300302
stdout := cfg.JailerCfg.Stdout
301303
if stdout == nil {
@@ -307,6 +309,11 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
307309
stderr = os.Stderr
308310
}
309311

312+
stdin := cfg.JailerCfg.Stdin
313+
if stdin == nil {
314+
stdin = os.Stdin
315+
}
316+
310317
m.cmd = NewJailerCommandBuilder().
311318
WithID(cfg.JailerCfg.ID).
312319
WithUID(*cfg.JailerCfg.UID).
@@ -318,6 +325,7 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
318325
WithSeccompLevel(cfg.JailerCfg.SeccompLevel).
319326
WithStdout(stdout).
320327
WithStderr(stderr).
328+
WithStdin(stdin).
321329
Build(ctx)
322330

323331
if err := cfg.JailerCfg.ChrootStrategy.AdaptHandlers(&m.Handlers); err != nil {

jailer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func TestJail(t *testing.T) {
146146
t.Errorf("expected args %v, but received %v", e, a)
147147
}
148148

149-
if e, a := filepath.Join(defaultJailerPath, cfg.JailerCfg.ID, "api.socket"), cfg.SocketPath; e != a {
149+
if e, a := filepath.Join(defaultJailerPath, cfg.JailerCfg.ID, rootfsFolderName, "api.socket"), cfg.SocketPath; e != a {
150150
t.Errorf("expected socket path %q, but received %q", e, a)
151151
}
152152

machine.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,13 @@ func (m *Machine) startVMM(ctx context.Context) error {
366366
return err
367367
}
368368
go func() {
369-
err := <-errCh
370-
m.err = err
369+
select {
370+
case <-ctx.Done():
371+
m.err = ctx.Err()
372+
case err := <-errCh:
373+
m.err = err
374+
}
375+
371376
close(m.exitCh)
372377
}()
373378

0 commit comments

Comments
 (0)