Skip to content

Commit 9c40863

Browse files
committed
Address comments
Signed-off-by: Serguei Bezverkhi <[email protected]>
1 parent 7a0c618 commit 9c40863

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

cmd/livenessprobe_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ func TestProbe(t *testing.T) {
7171
defer csiConn.Close()
7272

7373
var injectedErr error
74+
75+
// Setting up expected calls' responses
76+
inPlugin := &csi.GetPluginInfoRequest{}
77+
outPlugin := &csi.GetPluginInfoResponse{
78+
Name: "foo/bar",
79+
}
80+
idServer.EXPECT().GetPluginInfo(gomock.Any(), inPlugin).Return(outPlugin, injectedErr).Times(1)
81+
7482
inProbe := &csi.ProbeRequest{}
7583
outProbe := &csi.ProbeResponse{}
7684
idServer.EXPECT().Probe(gomock.Any(), inProbe).Return(outProbe, injectedErr).Times(1)

cmd/main.go

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ var (
4242
)
4343

4444
func runProbe(ctx context.Context, csiConn connection.CSIConnection) error {
45+
// Get CSI driver name.
46+
glog.Infof("Calling CSI driver to discover driver name.")
47+
csiDriverName, err := csiConn.GetDriverName(ctx)
48+
if err != nil {
49+
return err
50+
}
51+
glog.Infof("CSI driver name: %q", csiDriverName)
4552
// Sending Probe request
4653
glog.Infof("Sending probe request to CSI driver.")
4754
if err := csiConn.LivenessProbe(ctx); err != nil {

pkg/connection/connection.go

-19
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ type CSIConnection interface {
3636
// call.
3737
GetDriverName(ctx context.Context) (string, error)
3838

39-
// NodeGetId returns node ID of the current according to the CSI driver.
40-
NodeGetId(ctx context.Context) (string, error)
41-
4239
// Liveness Probe
4340
LivenessProbe(ctx context.Context) error
4441

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

129-
func (c *csiConnection) NodeGetId(ctx context.Context) (string, error) {
130-
client := csi.NewNodeClient(c.conn)
131-
132-
req := csi.NodeGetIdRequest{}
133-
134-
rsp, err := client.NodeGetId(ctx, &req)
135-
if err != nil {
136-
return "", err
137-
}
138-
nodeID := rsp.GetNodeId()
139-
if nodeID == "" {
140-
return "", fmt.Errorf("node ID is empty")
141-
}
142-
return nodeID, nil
143-
}
144-
145126
func (c *csiConnection) Close() error {
146127
return c.conn.Close()
147128
}

0 commit comments

Comments
 (0)