Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
  • Loading branch information
sbezverk committed Nov 1, 2018
1 parent 7a0c618 commit 9c40863
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
8 changes: 8 additions & 0 deletions cmd/livenessprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ func TestProbe(t *testing.T) {
defer csiConn.Close()

var injectedErr error

// Setting up expected calls' responses
inPlugin := &csi.GetPluginInfoRequest{}
outPlugin := &csi.GetPluginInfoResponse{
Name: "foo/bar",
}
idServer.EXPECT().GetPluginInfo(gomock.Any(), inPlugin).Return(outPlugin, injectedErr).Times(1)

inProbe := &csi.ProbeRequest{}
outProbe := &csi.ProbeResponse{}
idServer.EXPECT().Probe(gomock.Any(), inProbe).Return(outProbe, injectedErr).Times(1)
Expand Down
7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ var (
)

func runProbe(ctx context.Context, csiConn connection.CSIConnection) error {
// Get CSI driver name.
glog.Infof("Calling CSI driver to discover driver name.")
csiDriverName, err := csiConn.GetDriverName(ctx)
if err != nil {
return err
}
glog.Infof("CSI driver name: %q", csiDriverName)
// Sending Probe request
glog.Infof("Sending probe request to CSI driver.")
if err := csiConn.LivenessProbe(ctx); err != nil {
Expand Down
19 changes: 0 additions & 19 deletions pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ type CSIConnection interface {
// call.
GetDriverName(ctx context.Context) (string, error)

// NodeGetId returns node ID of the current according to the CSI driver.
NodeGetId(ctx context.Context) (string, error)

// Liveness Probe
LivenessProbe(ctx context.Context) error

Expand Down Expand Up @@ -126,22 +123,6 @@ func (c *csiConnection) LivenessProbe(ctx context.Context) error {
return nil
}

func (c *csiConnection) NodeGetId(ctx context.Context) (string, error) {
client := csi.NewNodeClient(c.conn)

req := csi.NodeGetIdRequest{}

rsp, err := client.NodeGetId(ctx, &req)
if err != nil {
return "", err
}
nodeID := rsp.GetNodeId()
if nodeID == "" {
return "", fmt.Errorf("node ID is empty")
}
return nodeID, nil
}

func (c *csiConnection) Close() error {
return c.conn.Close()
}
Expand Down

0 comments on commit 9c40863

Please sign in to comment.