csi: send secrets with snapshot delete command (#26022)

so that -secret arguments make it to the CSI plugin
to carry out the snapshot deletion
This commit is contained in:
Daniel Bennett
2025-06-09 17:02:52 -04:00
committed by GitHub
parent 2cc598ef00
commit 8164d9e1d4
4 changed files with 22 additions and 4 deletions

3
.changelog/26022.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed -secret values not being sent with the `nomad volume snapshot delete` command
```

View File

@@ -47,6 +47,7 @@ type MockClientCSI struct {
NextNodeDetachError error
NextNodeExpandError error
LastNodeExpandRequest *cstructs.ClientCSINodeExpandVolumeRequest
LastDeleteSnapshotRequest *cstructs.ClientCSIControllerDeleteSnapshotRequest
}
func newMockClientCSI() *MockClientCSI {
@@ -93,6 +94,7 @@ func (c *MockClientCSI) ControllerCreateSnapshot(req *cstructs.ClientCSIControll
}
func (c *MockClientCSI) ControllerDeleteSnapshot(req *cstructs.ClientCSIControllerDeleteSnapshotRequest, resp *cstructs.ClientCSIControllerDeleteSnapshotResponse) error {
c.LastDeleteSnapshotRequest = req
return c.NextDeleteSnapshotError
}

View File

@@ -1627,7 +1627,10 @@ func (v *CSIVolume) DeleteSnapshot(args *structs.CSISnapshotDeleteRequest, reply
method := "ClientCSI.ControllerDeleteSnapshot"
cReq := &cstructs.ClientCSIControllerDeleteSnapshotRequest{ID: snap.ID}
cReq := &cstructs.ClientCSIControllerDeleteSnapshotRequest{
ID: snap.ID,
Secrets: snap.Secrets,
}
cReq.PluginID = plugin.ID
cResp := &cstructs.ClientCSIControllerDeleteSnapshotResponse{}
err = v.serializedControllerRPC(plugin.ID, func() error {

View File

@@ -1693,7 +1693,7 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
}
var resp0 structs.NodeUpdateResponse
err = client.RPC("Node.Register", req0, &resp0)
require.NoError(t, err)
must.NoError(t, err)
testutil.WaitForResult(func() (bool, error) {
nodes := srv.connectedNodes()
@@ -1721,7 +1721,7 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
}
}).Node
index++
require.NoError(t, state.UpsertNode(structs.MsgTypeTestSetup, index, node))
must.NoError(t, state.UpsertNode(structs.MsgTypeTestSetup, index, node))
// Delete the snapshot request
req1 := &structs.CSISnapshotDeleteRequest{
@@ -1733,6 +1733,7 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
{
ID: "snap-34567",
PluginID: "minnie",
Secrets: map[string]string{"super": "secret"},
},
},
WriteRequest: structs.WriteRequest{
@@ -1743,7 +1744,16 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
resp1 := &structs.CSISnapshotDeleteResponse{}
err = msgpackrpc.CallWithCodec(codec, "CSIVolume.DeleteSnapshot", req1, resp1)
require.NoError(t, err)
must.NoError(t, err)
must.Eq(t, &cstructs.ClientCSIControllerDeleteSnapshotRequest{
ID: "snap-34567",
Secrets: map[string]string{"super": "secret"},
CSIControllerQuery: cstructs.CSIControllerQuery{
ControllerNodeID: node.ID,
PluginID: "minnie",
},
}, fake.LastDeleteSnapshotRequest)
}
func TestCSIVolumeEndpoint_ListSnapshots(t *testing.T) {