mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Fix:globalmount path may be residual while pod creation-deletion
This commit is contained in:
@@ -703,6 +703,9 @@ func (c *csiDriverClient) nodeGetCapabilities(ctx context.Context) ([]*csipbv1.N
|
||||
req := &csipbv1.NodeGetCapabilitiesRequest{}
|
||||
resp, err := nodeClient.NodeGetCapabilities(ctx, req)
|
||||
if err != nil {
|
||||
if !isFinalError(err) {
|
||||
return []*csipbv1.NodeServiceCapability{}, volumetypes.NewUncertainProgressError(err.Error())
|
||||
}
|
||||
return []*csipbv1.NodeServiceCapability{}, err
|
||||
}
|
||||
return resp.GetCapabilities(), nil
|
||||
|
||||
@@ -28,6 +28,8 @@ import (
|
||||
|
||||
csipbv1 "github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
@@ -698,6 +700,27 @@ func TestClientNodeUnstageVolume(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeSupportsStageUnstageReturnNewUncertainProgressError(t *testing.T) {
|
||||
fakeCloser := fake.NewCloser(t)
|
||||
client := &csiDriverClient{
|
||||
driverName: "Fake Driver Name",
|
||||
nodeV1ClientCreator: func(addr csiAddr, m *MetricsManager) (csipbv1.NodeClient, io.Closer, error) {
|
||||
nodeClient := fake.NewNodeClient(true)
|
||||
nodeClient.SetGetCapabilitiesErr(status.Errorf(codes.Unavailable, "connection error"))
|
||||
return nodeClient, fakeCloser, nil
|
||||
},
|
||||
}
|
||||
|
||||
_, err := client.NodeSupportsStageUnstage(context.Background())
|
||||
|
||||
uncertainProgressError := volumetypes.IsUncertainProgressError(err)
|
||||
if !uncertainProgressError {
|
||||
t.Errorf("Expected IsUncertainProgressError to be true, got %v", uncertainProgressError)
|
||||
}
|
||||
|
||||
fakeCloser.Check()
|
||||
}
|
||||
|
||||
func TestClientNodeSupportsStageUnstage(t *testing.T) {
|
||||
testClientNodeSupportsCapabilities(t,
|
||||
func(client *csiDriverClient) (bool, error) {
|
||||
|
||||
@@ -89,6 +89,7 @@ type NodeClient struct {
|
||||
nodeVolumeStatsResp *csipb.NodeGetVolumeStatsResponse
|
||||
FakeNodeExpansionRequest *csipb.NodeExpandVolumeRequest
|
||||
nextErr error
|
||||
getCapabilitiesErr error
|
||||
}
|
||||
|
||||
// NewNodeClient returns fake node client
|
||||
@@ -150,6 +151,10 @@ func (f *NodeClient) SetNextError(err error) {
|
||||
f.nextErr = err
|
||||
}
|
||||
|
||||
func (f *NodeClient) SetGetCapabilitiesErr(err error) {
|
||||
f.getCapabilitiesErr = err
|
||||
}
|
||||
|
||||
func (f *NodeClient) SetNodeGetInfoResp(resp *csipb.NodeGetInfoResponse) {
|
||||
f.nodeGetInfoResp = resp
|
||||
}
|
||||
@@ -354,6 +359,10 @@ func (f *NodeClient) NodeGetCapabilities(ctx context.Context, in *csipb.NodeGetC
|
||||
resp := &csipb.NodeGetCapabilitiesResponse{
|
||||
Capabilities: []*csipb.NodeServiceCapability{},
|
||||
}
|
||||
if f.getCapabilitiesErr != nil {
|
||||
return resp, f.getCapabilitiesErr
|
||||
}
|
||||
|
||||
if f.stageUnstageSet {
|
||||
resp.Capabilities = append(resp.Capabilities, &csipb.NodeServiceCapability{
|
||||
Type: &csipb.NodeServiceCapability_Rpc{
|
||||
|
||||
Reference in New Issue
Block a user