mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
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:
3
.changelog/26022.txt
Normal file
3
.changelog/26022.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
csi: Fixed -secret values not being sent with the `nomad volume snapshot delete` command
|
||||
```
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user