diff --git a/.changelog/26022.txt b/.changelog/26022.txt new file mode 100644 index 000000000..cbe1dc2f8 --- /dev/null +++ b/.changelog/26022.txt @@ -0,0 +1,3 @@ +```release-note:bug +csi: Fixed -secret values not being sent with the `nomad volume snapshot delete` command +``` diff --git a/nomad/client_csi_endpoint_test.go b/nomad/client_csi_endpoint_test.go index 88b0168ff..d2d127584 100644 --- a/nomad/client_csi_endpoint_test.go +++ b/nomad/client_csi_endpoint_test.go @@ -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 } diff --git a/nomad/csi_endpoint.go b/nomad/csi_endpoint.go index 1370f3463..4258a532b 100644 --- a/nomad/csi_endpoint.go +++ b/nomad/csi_endpoint.go @@ -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 { diff --git a/nomad/csi_endpoint_test.go b/nomad/csi_endpoint_test.go index 971d403c3..2d71a0f46 100644 --- a/nomad/csi_endpoint_test.go +++ b/nomad/csi_endpoint_test.go @@ -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) {