Skip to content

Commit 2cdf737

Browse files
backport of commit 8164d9e (#26024)
Co-authored-by: Daniel Bennett <[email protected]>
1 parent d6a3bdc commit 2cdf737

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.changelog/26022.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
csi: Fixed -secret values not being sent with the `nomad volume snapshot delete` command
3+
```

nomad/client_csi_endpoint_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type MockClientCSI struct {
4747
NextNodeDetachError error
4848
NextNodeExpandError error
4949
LastNodeExpandRequest *cstructs.ClientCSINodeExpandVolumeRequest
50+
LastDeleteSnapshotRequest *cstructs.ClientCSIControllerDeleteSnapshotRequest
5051
}
5152

5253
func newMockClientCSI() *MockClientCSI {
@@ -93,6 +94,7 @@ func (c *MockClientCSI) ControllerCreateSnapshot(req *cstructs.ClientCSIControll
9394
}
9495

9596
func (c *MockClientCSI) ControllerDeleteSnapshot(req *cstructs.ClientCSIControllerDeleteSnapshotRequest, resp *cstructs.ClientCSIControllerDeleteSnapshotResponse) error {
97+
c.LastDeleteSnapshotRequest = req
9698
return c.NextDeleteSnapshotError
9799
}
98100

nomad/csi_endpoint.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,10 @@ func (v *CSIVolume) DeleteSnapshot(args *structs.CSISnapshotDeleteRequest, reply
16271627

16281628
method := "ClientCSI.ControllerDeleteSnapshot"
16291629

1630-
cReq := &cstructs.ClientCSIControllerDeleteSnapshotRequest{ID: snap.ID}
1630+
cReq := &cstructs.ClientCSIControllerDeleteSnapshotRequest{
1631+
ID: snap.ID,
1632+
Secrets: snap.Secrets,
1633+
}
16311634
cReq.PluginID = plugin.ID
16321635
cResp := &cstructs.ClientCSIControllerDeleteSnapshotResponse{}
16331636
err = v.serializedControllerRPC(plugin.ID, func() error {

nomad/csi_endpoint_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
16931693
}
16941694
var resp0 structs.NodeUpdateResponse
16951695
err = client.RPC("Node.Register", req0, &resp0)
1696-
require.NoError(t, err)
1696+
must.NoError(t, err)
16971697

16981698
testutil.WaitForResult(func() (bool, error) {
16991699
nodes := srv.connectedNodes()
@@ -1721,7 +1721,7 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
17211721
}
17221722
}).Node
17231723
index++
1724-
require.NoError(t, state.UpsertNode(structs.MsgTypeTestSetup, index, node))
1724+
must.NoError(t, state.UpsertNode(structs.MsgTypeTestSetup, index, node))
17251725

17261726
// Delete the snapshot request
17271727
req1 := &structs.CSISnapshotDeleteRequest{
@@ -1733,6 +1733,7 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
17331733
{
17341734
ID: "snap-34567",
17351735
PluginID: "minnie",
1736+
Secrets: map[string]string{"super": "secret"},
17361737
},
17371738
},
17381739
WriteRequest: structs.WriteRequest{
@@ -1743,7 +1744,16 @@ func TestCSIVolumeEndpoint_DeleteSnapshot(t *testing.T) {
17431744

17441745
resp1 := &structs.CSISnapshotDeleteResponse{}
17451746
err = msgpackrpc.CallWithCodec(codec, "CSIVolume.DeleteSnapshot", req1, resp1)
1746-
require.NoError(t, err)
1747+
must.NoError(t, err)
1748+
1749+
must.Eq(t, &cstructs.ClientCSIControllerDeleteSnapshotRequest{
1750+
ID: "snap-34567",
1751+
Secrets: map[string]string{"super": "secret"},
1752+
CSIControllerQuery: cstructs.CSIControllerQuery{
1753+
ControllerNodeID: node.ID,
1754+
PluginID: "minnie",
1755+
},
1756+
}, fake.LastDeleteSnapshotRequest)
17471757
}
17481758

17491759
func TestCSIVolumeEndpoint_ListSnapshots(t *testing.T) {

0 commit comments

Comments
 (0)