Skip to content

Commit 1e92349

Browse files
committed
support volume_mount in task
1 parent 4ab1c8f commit 1e92349

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

containerd/driver.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,22 @@ func NewPlugin(logger log.Logger) drivers.DriverPlugin {
229229
}
230230
}
231231

232+
func (tc *TaskConfig) setVolumeMounts(cfg *drivers.TaskConfig) {
233+
for _, m := range cfg.Mounts {
234+
hm := Mount{
235+
Type: "bind",
236+
Target: m.TaskPath,
237+
Source: m.HostPath,
238+
Options: []string{"rbind"},
239+
}
240+
if m.Readonly {
241+
hm.Options = append(hm.Options, "ro")
242+
}
243+
244+
tc.Mounts = append(tc.Mounts, hm)
245+
}
246+
}
247+
232248
// PluginInfo returns information describing the plugin.
233249
func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error) {
234250
return pluginInfo, nil
@@ -345,6 +361,8 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
345361
return nil, nil, fmt.Errorf("host_network and bridge network mode are mutually exclusive, and only one of them should be set")
346362
}
347363

364+
driverConfig.setVolumeMounts(cfg)
365+
348366
d.logger.Info("starting task", "driver_cfg", hclog.Fmt("%+v", driverConfig))
349367
handle := drivers.NewTaskHandle(taskHandleVersion)
350368
handle.Config = cfg

0 commit comments

Comments
 (0)