Skip to content

Commit

Permalink
CSI - Multiple bug fixes for NodeProbe, vol data file, mount dir create
Browse files Browse the repository at this point in the history
-  NodeProbe rpc before node attach
-  Teardown fix using  volume info data file stored on node
-  Pre-create the mount prior to calling nodepublish
  • Loading branch information
vladimirvivien committed Dec 8, 2017
1 parent a6741ea commit 23d59cb
Show file tree
Hide file tree
Showing 8 changed files with 408 additions and 97 deletions.
2 changes: 1 addition & 1 deletion pkg/volume/csi/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_library(
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//vendor/github.com/container-storage-interface/spec/lib/go/csi:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
Expand All @@ -38,7 +39,6 @@ go_test(
importpath = "k8s.io/kubernetes/pkg/volume/csi",
library = ":go_default_library",
deps = [
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/csi/fake:go_default_library",
"//pkg/volume/testing:go_default_library",
Expand Down
12 changes: 10 additions & 2 deletions pkg/volume/csi/csi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

type csiClient interface {
AssertSupportedVersion(ctx grpctx.Context, ver *csipb.Version) error
NodeProbe(ctx grpctx.Context, ver *csipb.Version) error
NodePublishVolume(
ctx grpctx.Context,
volumeid string,
Expand Down Expand Up @@ -135,6 +136,13 @@ func (c *csiDriverClient) AssertSupportedVersion(ctx grpctx.Context, ver *csipb.
return nil
}

func (c *csiDriverClient) NodeProbe(ctx grpctx.Context, ver *csipb.Version) error {
glog.V(4).Info(log("sending NodeProbe rpc call to csi driver: [version %v]", ver))
req := &csipb.NodeProbeRequest{Version: ver}
_, err := c.nodeClient.NodeProbe(ctx, req)
return err
}

func (c *csiDriverClient) NodePublishVolume(
ctx grpctx.Context,
volID string,
Expand All @@ -145,7 +153,7 @@ func (c *csiDriverClient) NodePublishVolume(
volumeAttribs map[string]string,
fsType string,
) error {

glog.V(4).Info(log("calling NodePublishVolume rpc [volid=%s,target_path=%s]", volID, targetPath))
if volID == "" {
return errors.New("missing volume id")
}
Expand Down Expand Up @@ -182,7 +190,7 @@ func (c *csiDriverClient) NodePublishVolume(
}

func (c *csiDriverClient) NodeUnpublishVolume(ctx grpctx.Context, volID string, targetPath string) error {

glog.V(4).Info(log("calling NodeUnpublishVolume rpc: [volid=%s, target_path=%s", volID, targetPath))
if volID == "" {
return errors.New("missing volume id")
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/volume/csi/csi_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ func TestClientAssertSupportedVersion(t *testing.T) {
}
}

func TestClientNodeProbe(t *testing.T) {
testCases := []struct {
testName string
ver *csipb.Version
mustFail bool
err error
}{
{testName: "supported version", ver: &csipb.Version{Major: 0, Minor: 1, Patch: 0}},
{testName: "grpc error", ver: &csipb.Version{Major: 0, Minor: 1, Patch: 0}, mustFail: true, err: errors.New("grpc error")},
}

for _, tc := range testCases {
t.Log("case: ", tc.testName)
client := setupClient(t)
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
err := client.NodeProbe(grpctx.Background(), tc.ver)
if tc.mustFail && err == nil {
t.Error("must fail, but err = nil")
}
}
}

func TestClientNodePublishVolume(t *testing.T) {
testCases := []struct {
name string
Expand Down
Loading

0 comments on commit 23d59cb

Please sign in to comment.