@@ -38,7 +38,6 @@ import (
3838 "github.com/hashicorp/nomad/plugins/drivers"
3939 "github.com/hashicorp/nomad/plugins/shared/hclspec"
4040 "github.com/hashicorp/nomad/plugins/shared/structs"
41- "github.com/opencontainers/runc/libcontainer/cgroups"
4241)
4342
4443const (
@@ -263,16 +262,7 @@ type Driver struct {
263262func NewPlugin (logger log.Logger ) drivers.DriverPlugin {
264263 ctx , cancel := context .WithCancel (context .Background ())
265264 logger = logger .Named (PluginName )
266-
267- // Calls to containerd API are namespaced.
268- // "nomad" is the namespace that will be used for all nomad-driver-containerd
269- // related containerd API calls.
270- namespace := "nomad"
271- // Unless we are operating in cgroups.v2 mode, in which case we use the
272- // name "nomad.slice", which ends up being the cgroup parent.
273- if cgroups .IsCgroup2UnifiedMode () {
274- namespace = "nomad.slice"
275- }
265+ namespace := getNamespaceName ()
276266 ctxContainerd := namespaces .WithNamespace (context .Background (), namespace )
277267
278268 return & Driver {
@@ -451,13 +441,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
451441 handle := drivers .NewTaskHandle (taskHandleVersion )
452442 handle .Config = cfg
453443
454- // Use Nomad's docker naming convention for the container name
455- // https://www.nomadproject.io/docs/drivers/docker#container-name
456- containerName := cfg .Name + "-" + cfg .AllocID
457- if cgroups .IsCgroup2UnifiedMode () {
458- // In cgroup.v2 mode, the name is slightly different.
459- containerName = fmt .Sprintf ("%s.%s.scope" , cfg .AllocID , cfg .Name )
460- }
444+ containerName := getContainerName (cfg .Name , cfg .AllocID )
461445 containerConfig .ContainerName = containerName
462446
463447 var err error
0 commit comments