Skip to content

Commit 1823e67

Browse files
authored
drivers: include volume within mount config (#27710)
Add an optional `RequestName` attribute to the mount config. If the mount config entry originated from a volume, the request name of the volume used within the jobspec will be included within the entry.
1 parent cb498b9 commit 1823e67

9 files changed

Lines changed: 276 additions & 246 deletions

File tree

.changelog/27710.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
drivers: include volume RequestName within mount config information if available
3+
```

.changelog/27711.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
drivers: kill plugin instance on dispense failure
3+
```

client/allocrunner/taskrunner/volume_hook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (h *volumeHook) hostVolumeMountConfigurations(taskMounts []*structs.VolumeM
9191
}
9292

9393
mcfg := &drivers.MountConfig{
94+
RequestName: hostVolume.Name,
9495
HostPath: hostVolume.Path,
9596
TaskPath: m.Destination,
9697
Readonly: hostVolume.ReadOnly || req.ReadOnly || m.ReadOnly,
@@ -185,6 +186,7 @@ func (h *volumeHook) prepareCSIVolumes(req *interfaces.TaskPrestartRequest, volu
185186

186187
for _, m := range mountsForAlias {
187188
mcfg := &drivers.MountConfig{
189+
RequestName: request.Name,
188190
HostPath: csiMountPoint.Source,
189191
TaskPath: m.Destination,
190192
Readonly: request.ReadOnly || m.ReadOnly,

client/allocrunner/taskrunner/volume_hook_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func TestVolumeHook_prepareCSIVolumes(t *testing.T) {
9191

9292
volumes := map[string]*structs.VolumeRequest{
9393
"foo": {
94+
Name: "foo",
9495
Type: "csi",
9596
Source: "my-test-volume",
9697
},
@@ -113,8 +114,9 @@ func TestVolumeHook_prepareCSIVolumes(t *testing.T) {
113114
},
114115
Expected: []*drivers.MountConfig{
115116
{
116-
HostPath: "/mnt/my-test-volume",
117-
TaskPath: "/bar",
117+
RequestName: "foo",
118+
HostPath: "/mnt/my-test-volume",
119+
TaskPath: "/bar",
118120
},
119121
},
120122
},

plugins/drivers/driver.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ func (d *DeviceConfig) Copy() *DeviceConfig {
444444
}
445445

446446
type MountConfig struct {
447+
RequestName string
447448
TaskPath string
448449
HostPath string
449450
Readonly bool
@@ -456,7 +457,8 @@ func (m *MountConfig) IsEqual(o *MountConfig) bool {
456457
m.HostPath == o.HostPath &&
457458
m.Readonly == o.Readonly &&
458459
m.PropagationMode == o.PropagationMode &&
459-
m.SELinuxLabel == o.SELinuxLabel
460+
m.SELinuxLabel == o.SELinuxLabel &&
461+
m.RequestName == o.RequestName
460462
}
461463

462464
func (m *MountConfig) Copy() *MountConfig {

plugins/drivers/proto/driver.pb.go

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

plugins/drivers/proto/driver.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ message Mount {
600600
string propagation_mode = 4;
601601

602602
string selinux_label = 5;
603+
604+
// RequestName is the optional name of the volume request in the job spec
605+
// from which this mount originated.
606+
string request_name = 6;
603607
}
604608

605609
message Device {

plugins/drivers/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ func MountFromProto(mount *proto.Mount) *MountConfig {
290290
}
291291

292292
return &MountConfig{
293+
RequestName: mount.RequestName,
293294
TaskPath: mount.TaskPath,
294295
HostPath: mount.HostPath,
295296
Readonly: mount.Readonly,
@@ -342,6 +343,7 @@ func MountToProto(mount *MountConfig) *proto.Mount {
342343
}
343344

344345
return &proto.Mount{
346+
RequestName: mount.RequestName,
345347
TaskPath: mount.TaskPath,
346348
HostPath: mount.HostPath,
347349
Readonly: mount.Readonly,

plugins/drivers/utils_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func TestTaskConfigRoundTrip(t *testing.T) {
8383
},
8484
Mounts: []*MountConfig{
8585
{
86+
RequestName: "volume",
8687
TaskPath: "task",
8788
HostPath: "host",
8889
Readonly: true,

0 commit comments

Comments
 (0)