Skip to content

Commit

Permalink
CSI: include volume namespace in staging path (#20532)
Browse files Browse the repository at this point in the history
CSI volumes are namespaced. But the client does not include the namespace in the
staging mount path. This causes CSI volumes with the same volume ID but
different namespace to collide if they happen to be placed on the same host. The
per-allocation paths don't need to be namespaced, because an allocation can only
mount volumes from its job's own namespace.

Rework the CSI hook tests to have more fine-grained control over the mock
on-disk state. Add tests covering upgrades from staging paths missing
namespaces.

Fixes: #18741
  • Loading branch information
tgross committed May 13, 2024
1 parent 623486b commit 65ae612
Show file tree
Hide file tree
Showing 14 changed files with 318 additions and 152 deletions.
3 changes: 3 additions & 0 deletions .changelog/20532.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where volumes in different namespaces but the same ID would fail to stage on the same client
```
4 changes: 3 additions & 1 deletion client/allocrunner/csi_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func (c *csiHook) claimVolumes(results map[string]*volumePublishResult) error {

// populate data we'll write later to disk
result.stub.VolumeID = resp.Volume.ID
result.stub.VolumeNamespace = resp.Volume.Namespace
result.stub.VolumeExternalID = resp.Volume.RemoteID()
result.stub.PluginID = resp.Volume.PluginID
result.publishContext = resp.PublishContext
Expand Down Expand Up @@ -532,7 +533,8 @@ func (c *csiHook) unmountImpl(result *volumePublishResult) error {
}

return manager.UnmountVolume(c.shutdownCtx,
result.stub.VolumeID, result.stub.VolumeExternalID, c.alloc.ID, usageOpts)
result.stub.VolumeNamespace, result.stub.VolumeID,
result.stub.VolumeExternalID, c.alloc.ID, usageOpts)
}

// Shutdown will get called when the client is gracefully
Expand Down

0 comments on commit 65ae612

Please sign in to comment.