Skip to content

Commit 2e4e8c5

Browse files
committed
fixup! Adds cgroup path to CreateVMResponse
Signed-off-by: xibz <[email protected]>
1 parent cfb4554 commit 2e4e8c5

File tree

7 files changed

+78
-90
lines changed

7 files changed

+78
-90
lines changed

proto/firecracker.pb.go

Lines changed: 44 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/firecracker.proto

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ message CreateVMRequest {
3838

3939
message CreateVMResponse {
4040
string VMID = 1;
41-
uint32 ContextID = 2;
42-
string SocketPath = 3;
43-
string LogFifoPath = 4;
44-
string MetricsFifoPath = 5;
45-
string CgroupPath = 6;
41+
string SocketPath = 2;
42+
string LogFifoPath = 3;
43+
string MetricsFifoPath = 4;
44+
string CgroupPath = 5;
4645
}
4746

4847
message StopVMRequest {
@@ -56,11 +55,10 @@ message GetVMInfoRequest {
5655

5756
message GetVMInfoResponse {
5857
string VMID = 1;
59-
uint32 ContextID = 2;
60-
string SocketPath = 3;
61-
string LogFifoPath = 4;
62-
string MetricsFifoPath = 5;
63-
string CgroupPath = 6;
58+
string SocketPath = 2;
59+
string LogFifoPath = 3;
60+
string MetricsFifoPath = 4;
61+
string CgroupPath = 5;
6462
}
6563

6664
message SetVMMetadataRequest {

runtime/jailer.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,13 @@ func newJailer(
7777
}
7878

7979
l := logger.WithField("jailer", "runc")
80-
return newRuncJailer(ctx, l, ociBundlePath, service, jailerUID, jailerGID)
80+
return newRuncJailer(
81+
ctx,
82+
l,
83+
service.vmID,
84+
ociBundlePath,
85+
service.config.JailerConfig.RuncBinaryPath,
86+
jailerUID,
87+
jailerGID,
88+
)
8189
}

runtime/noop_jailer.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,3 @@ func (j noopJailer) StubDrivesOptions() []stubDrivesOpt {
7777
j.logger.Debug("noop operation for StubDrivesOptions")
7878
return []stubDrivesOpt{}
7979
}
80-
81-
func (j noopJailer) CgroupPath() string {
82-
j.logger.Debug("noop operation for CgroupPath")
83-
return ""
84-
}

runtime/runc_jailer.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,23 @@ type runcJailer struct {
5656

5757
const firecrackerFileName = "firecracker"
5858

59-
func newRuncJailer(ctx context.Context, logger *logrus.Entry, ociBundlePath string, service *service, uid, gid uint32) (*runcJailer, error) {
60-
l := logger.WithField("ociBundlePath", ociBundlePath).
61-
WithField("runcBinaryPath", service.config.JailerConfig.RuncBinaryPath)
62-
59+
func newRuncJailer(
60+
ctx context.Context,
61+
logger *logrus.Entry,
62+
vmID string,
63+
ociBundlePath string,
64+
runcBinaryPath string,
65+
uid uint32,
66+
gid uint32) (*runcJailer, error) {
67+
l := logger.WithField("ociBundlePath", ociBundlePath).WithField("runcBinaryPath", runcBinaryPath)
6368
j := &runcJailer{
6469
ctx: ctx,
6570
logger: l,
6671
ociBundlePath: ociBundlePath,
67-
runcBinaryPath: service.config.JailerConfig.RuncBinaryPath,
72+
runcBinaryPath: runcBinaryPath,
6873
uid: uid,
6974
gid: gid,
70-
vmID: service.vmID,
75+
vmID: vmID,
7176
}
7277

7378
spec := specs.Spec{}
@@ -442,7 +447,9 @@ func (j *runcJailer) setDefaultConfigValues(cfg *Config, socketPath string, spec
442447
spec.Process.Args = cmd.Args
443448
}
444449

445-
spec.Linux.CgroupsPath = j.CgroupPath()
450+
cgroupPath := j.CgroupPath()
451+
j.logger.WithField("CgroupPath", cgroupPath).Debug("using cgroup path")
452+
spec.Linux.CgroupsPath = cgroupPath
446453

447454
return spec
448455
}

runtime/runc_jailer_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
5353
defer firecrackerFd.Close()
5454

5555
l := logrus.NewEntry(logrus.New())
56-
s := &service{
57-
config: &Config{
58-
JailerConfig: JailerConfig{},
59-
},
60-
}
61-
jailer, err := newRuncJailer(context.Background(), l, dir, s, 123, 456)
56+
vmID := "foo"
57+
jailer, err := newRuncJailer(context.Background(), l, vmID, dir, "path/to/runc", 123, 456)
6258
require.NoError(t, err, "failed to create runc jailer")
6359

6460
cfg := Config{

runtime/service_integ_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ func TestMultipleVMs_Isolated(t *testing.T) {
410410
require.NoError(t, err, "failed to stat root path of jailer")
411411
_, err = os.Stat(filepath.Join("/sys/fs/cgroup/cpu", resp.CgroupPath))
412412
require.NoError(t, err, "failed to stat cgroup path of jailer")
413+
assert.Equal(t, filepath.Join("/firecracker-containerd", vmIDStr), resp.CgroupPath)
413414
}
414415

415416
// Verify each exec had the same stdout and use that value as the mount namespace that will be compared

0 commit comments

Comments
 (0)