Skip to content

Commit 1af1514

Browse files
authored
Merge pull request #355 from kubernetes-sigs/remove-instanceid-check
fix: remove InstanceID check in ControllerPublishVolume
2 parents d0f3f2f + 0223b6f commit 1af1514

File tree

3 files changed

+2
-29
lines changed

3 files changed

+2
-29
lines changed

pkg/azurefile/controllerserver.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ import (
3131
"github.com/pborman/uuid"
3232
"google.golang.org/grpc/codes"
3333
"google.golang.org/grpc/status"
34-
"k8s.io/apimachinery/pkg/types"
3534
"k8s.io/apimachinery/pkg/util/wait"
36-
cloudprovider "k8s.io/cloud-provider"
3735
"k8s.io/klog/v2"
3836
"k8s.io/legacy-cloud-providers/azure"
3937
"k8s.io/legacy-cloud-providers/azure/clients/fileclient"
@@ -343,13 +341,6 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
343341
if len(nodeID) == 0 {
344342
return nil, status.Error(codes.InvalidArgument, "Node ID not provided")
345343
}
346-
nodeName := types.NodeName(nodeID)
347-
if _, err := d.cloud.InstanceID(ctx, nodeName); err != nil {
348-
if err == cloudprovider.InstanceNotFound {
349-
return nil, status.Error(codes.NotFound, fmt.Sprintf("failed to get azure instance id for node %q (%v)", nodeName, err))
350-
}
351-
return nil, status.Error(codes.Internal, fmt.Sprintf("get azure instance id for node %q failed with %v", nodeName, err))
352-
}
353344

354345
_, accountName, accountKey, fileShareName, diskName, err := d.GetAccountInfo(volumeID, req.GetSecrets(), req.GetVolumeContext())
355346
// always check diskName first since if it's not vhd disk attach, ControllerPublishVolume is not necessary

pkg/azurefile/controllerserver_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,24 +1010,6 @@ func TestControllerPublishVolume(t *testing.T) {
10101010
},
10111011
expectedErr: status.Error(codes.InvalidArgument, "Node ID not provided"),
10121012
},
1013-
{
1014-
desc: "Instance not found",
1015-
req: &csi.ControllerPublishVolumeRequest{
1016-
VolumeId: "vol_1",
1017-
VolumeCapability: &stdVolCap,
1018-
NodeId: "vm1",
1019-
},
1020-
expectedErr: status.Error(codes.NotFound, "failed to get azure instance id for node \"vm1\" (instance not found)"),
1021-
},
1022-
{
1023-
desc: "Get azure instance returns error",
1024-
req: &csi.ControllerPublishVolumeRequest{
1025-
VolumeId: "vol_1",
1026-
VolumeCapability: &stdVolCap,
1027-
NodeId: "vm2",
1028-
},
1029-
expectedErr: status.Error(codes.Internal, "get azure instance id for node \"vm2\" failed with Retriable: false, RetryAfter: 0s, HTTPStatusCode: 502, RawError: instance not found"),
1030-
},
10311013
{
10321014
desc: "Valid request disk name empty",
10331015
req: &csi.ControllerPublishVolumeRequest{

test/sanity/run-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ _output/azurefileplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 &
3535

3636
echo 'Begin to run sanity test...'
3737
readonly CSI_SANITY_BIN='csi-test/cmd/csi-sanity/csi-sanity'
38-
"$CSI_SANITY_BIN" --ginkgo.v --ginkgo.noColor --csi.endpoint="$endpoint" --ginkgo.skip='should fail when the volume source snapshot is not found|should work'
38+
"$CSI_SANITY_BIN" --ginkgo.v --ginkgo.noColor --csi.endpoint="$endpoint" --ginkgo.skip='should fail when the volume source snapshot is not found|should work|should fail when the volume does not exist|should fail when the node does not exist'
3939

4040
testvolumeparameters='/tmp/vhd.yaml'
4141
cat > $testvolumeparameters << EOF
4242
fstype: ext4
4343
EOF
4444

4545
echo 'Begin to run sanity test for vhd disk feature...'
46-
"$CSI_SANITY_BIN" --ginkgo.v --ginkgo.noColor --csi.endpoint="$endpoint" --csi.testvolumeparameters="$testvolumeparameters" --ginkgo.skip='should fail when the volume source snapshot is not found|should work|should fail when volume does not exist on the specified path'
46+
"$CSI_SANITY_BIN" --ginkgo.v --ginkgo.noColor --csi.endpoint="$endpoint" --csi.testvolumeparameters="$testvolumeparameters" --ginkgo.skip='should fail when the volume source snapshot is not found|should work|should fail when volume does not exist on the specified path|should fail when the volume does not exist|should fail when the node does not exist'

0 commit comments

Comments
 (0)