Skip to content

Commit 001a3a2

Browse files
committed
Make NUMA node to be optional
Signed-off-by: Gudmundur Bjarni Olafsson <[email protected]>
1 parent aa97886 commit 001a3a2

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

handlers.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ var JailerConfigValidationHandler = Handler{
109109
return fmt.Errorf("UID must be specified when using jailer mode")
110110
}
111111

112-
if m.Cfg.JailerCfg.NumaNode == nil {
113-
return fmt.Errorf("ID must be specified when using jailer mode")
114-
}
115-
116112
return nil
117113
},
118114
}

jailer.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ type JailerCommandBuilder struct {
102102
uid int
103103
gid int
104104
execFile string
105-
node int
106105

107106
// optional params
108107
chrootBaseDir string
109108
netNS string
110109
daemonize bool
111110
firecrackerArgs []string
112111
cgroupVersion string
112+
node *int
113113

114114
stdin io.Reader
115115
stdout io.Writer
@@ -139,9 +139,11 @@ func (b JailerCommandBuilder) Args() []string {
139139
args = append(args, "--gid", strconv.Itoa(b.gid))
140140
args = append(args, "--exec-file", b.execFile)
141141

142-
if cpulist := getNumaCpuset(b.node); len(cpulist) > 0 {
143-
args = append(args, "--cgroup", fmt.Sprintf("cpuset.mems=%d", b.node))
144-
args = append(args, "--cgroup", fmt.Sprintf("cpuset.cpus=%s", cpulist))
142+
if b.node != nil {
143+
if cpulist := getNumaCpuset(*b.node); len(cpulist) > 0 {
144+
args = append(args, "--cgroup", fmt.Sprintf("cpuset.mems=%d", b.node))
145+
args = append(args, "--cgroup", fmt.Sprintf("cpuset.cpus=%s", cpulist))
146+
}
145147
}
146148

147149
if len(b.cgroupVersion) > 0 {
@@ -208,7 +210,7 @@ func (b JailerCommandBuilder) WithExecFile(path string) JailerCommandBuilder {
208210
// WithNumaNode uses the specfied node for the jailer. This represents the numa
209211
// node that the process will get assigned to.
210212
func (b JailerCommandBuilder) WithNumaNode(node int) JailerCommandBuilder {
211-
b.node = node
213+
b.node = &node
212214
return b
213215
}
214216

@@ -344,7 +346,6 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
344346
WithID(cfg.JailerCfg.ID).
345347
WithUID(*cfg.JailerCfg.UID).
346348
WithGID(*cfg.JailerCfg.GID).
347-
WithNumaNode(*cfg.JailerCfg.NumaNode).
348349
WithExecFile(cfg.JailerCfg.ExecFile).
349350
WithChrootBaseDir(cfg.JailerCfg.ChrootBaseDir).
350351
WithDaemonize(cfg.JailerCfg.Daemonize).
@@ -365,6 +366,10 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
365366
builder = builder.WithStdin(stdin)
366367
}
367368

369+
if cfg.JailerCfg.NumaNode != nil {
370+
builder = builder.WithNumaNode(*cfg.JailerCfg.NumaNode)
371+
}
372+
368373
m.cmd = builder.Build(ctx)
369374

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

0 commit comments

Comments
 (0)