From 44a59710ea285269b256c617eb2349beef086328 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Mon, 15 Aug 2022 16:32:23 +0200 Subject: [PATCH] Fix failing `test/e2e/storage/csi_mock_volume.go` test Followup on https://github.com/kubernetes/kubernetes/pull/111846. This particular test was left out from that PR because once it was enabled it started failing. It was desired to merge https://github.com/kubernetes/kubernetes/pull/111846 irrespective of this particular test. The failure in the test was caused due to the `createFSGroupRequestPreHook` mock CSI driver hook function assuming that the request object passed to it is an instance of the respective struct, but it's actually a pointer instead. This resulted in the hook function not fulfilling its purpose, and the so the test failed. --- test/e2e/storage/csi_mock_volume.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/storage/csi_mock_volume.go b/test/e2e/storage/csi_mock_volume.go index 5de77f69c7f..795391dc2c4 100644 --- a/test/e2e/storage/csi_mock_volume.go +++ b/test/e2e/storage/csi_mock_volume.go @@ -1731,8 +1731,8 @@ var _ = utils.SIGDescribe("CSI mock volume", func() { }, } for _, t := range tests { - test := t - ginkgo.It(test.name, func() { + t := t + ginkgo.It(t.name, func() { var nodeStageFsGroup, nodePublishFsGroup string if framework.NodeOSDistroIs("windows") { e2eskipper.Skipf("FSGroupPolicy is only applied on linux nodes -- skipping") @@ -1740,7 +1740,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() { init(testParameters{ disableAttach: true, registerDriver: true, - enableVolumeMountGroup: test.enableVolumeMountGroup, + enableVolumeMountGroup: t.enableVolumeMountGroup, hooks: createFSGroupRequestPreHook(&nodeStageFsGroup, &nodePublishFsGroup), }) defer cleanup() @@ -2479,14 +2479,14 @@ func createPreHook(method string, callback func(counter int64) error) *drivers.H func createFSGroupRequestPreHook(nodeStageFsGroup, nodePublishFsGroup *string) *drivers.Hooks { return &drivers.Hooks{ Pre: func(ctx context.Context, fullMethod string, request interface{}) (reply interface{}, err error) { - nodeStageRequest, ok := request.(csipbv1.NodeStageVolumeRequest) + nodeStageRequest, ok := request.(*csipbv1.NodeStageVolumeRequest) if ok { mountVolume := nodeStageRequest.GetVolumeCapability().GetMount() if mountVolume != nil { *nodeStageFsGroup = mountVolume.VolumeMountGroup } } - nodePublishRequest, ok := request.(csipbv1.NodePublishVolumeRequest) + nodePublishRequest, ok := request.(*csipbv1.NodePublishVolumeRequest) if ok { mountVolume := nodePublishRequest.GetVolumeCapability().GetMount() if mountVolume != nil {