Skip to content

Commit

Permalink
drivers/exec: pass capabilities through executor RPC
Browse files Browse the repository at this point in the history
Add capabilities to the LaunchRequest proto so that the
capabilities set actually gets plumbed all the way through
to task launch.
  • Loading branch information
shoenig committed May 16, 2021
1 parent a442349 commit 1b382f5
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 68 deletions.
1 change: 1 addition & 0 deletions drivers/exec/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
if err != nil {
return nil, nil, err
}
d.logger.Debug("task capabilities", "capabilities", caps)

execCmd := &executor.ExecCommand{
Cmd: driverConfig.Command,
Expand Down
1 change: 1 addition & 0 deletions drivers/java/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
if err != nil {
return nil, nil, err
}
d.logger.Debug("task capabilities", "capabilities", caps)

execCmd := &executor.ExecCommand{
Cmd: absPath,
Expand Down
1 change: 1 addition & 0 deletions drivers/shared/executor/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (c *grpcExecutorClient) Launch(cmd *ExecCommand) (*ProcessState, error) {
NetworkIsolation: drivers.NetworkIsolationSpecToProto(cmd.NetworkIsolation),
DefaultPidMode: cmd.ModePID,
DefaultIpcMode: cmd.ModeIPC,
Capabilities: cmd.Capabilities,
}
resp, err := c.client.Launch(ctx, req)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions drivers/shared/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ type Executor interface {

// ExecCommand holds the user command, args, and other isolation related
// settings.
//
// Important (!): when adding fields, make sure to update the RPC methods in
// grpcExecutorClient.Launch and grpcExecutorServer.Launch. Number of hours
// spent tracking this down: too many.
type ExecCommand struct {
// Cmd is the command that the user wants to run.
Cmd string
Expand Down
1 change: 0 additions & 1 deletion drivers/shared/executor/executor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ func (l *LibcontainerExecutor) handleExecWait(ch chan *waitResult, process *libc
}

func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) {

switch command.User {
case "root":
// when running as root, use the legacy set of system capabilities, so
Expand Down
143 changes: 76 additions & 67 deletions drivers/shared/executor/proto/executor.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions drivers/shared/executor/proto/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ message LaunchRequest {
string default_ipc_mode = 16;
string cpuset_cgroup = 17;
repeated string allow_caps = 18;
repeated string capabilities = 19;
}

message LaunchResponse {
Expand Down
1 change: 1 addition & 0 deletions drivers/shared/executor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchReques
NetworkIsolation: drivers.NetworkIsolationSpecFromProto(req.NetworkIsolation),
ModePID: req.DefaultPidMode,
ModeIPC: req.DefaultIpcMode,
Capabilities: req.Capabilities,
})

if err != nil {
Expand Down

0 comments on commit 1b382f5

Please sign in to comment.