Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions manager/csi/fakes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package csi
import (
"context"
"fmt"
"net"
"strings"
"sync"

Expand Down Expand Up @@ -209,6 +210,7 @@ func (fpm *fakePluginMaker) newFakePlugin(pa mobyplugin.AddrPlugin, provider Sec
p := &fakePlugin{
name: pa.Name(),
socket: pa.Addr().String(),
addr: pa.Addr(),
swarmToCSI: map[string]string{},
volumesCreated: map[string]*api.Volume{},
volumesDeleted: []string{},
Expand All @@ -223,6 +225,7 @@ func (fpm *fakePluginMaker) newFakePlugin(pa mobyplugin.AddrPlugin, provider Sec
type fakePlugin struct {
name string
socket string
addr net.Addr
swarmToCSI map[string]string
// removedIDs is a set of node IDs for which RemoveNode has been called.
removedIDs map[string]struct{}
Expand Down Expand Up @@ -287,3 +290,7 @@ func (f *fakePlugin) AddNode(swarmID, csiID string) {
func (f *fakePlugin) RemoveNode(swarmID string) {
f.removedIDs[swarmID] = struct{}{}
}

func (f *fakePlugin) Addr() net.Addr {
return f.addr
}
8 changes: 8 additions & 0 deletions manager/csi/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net"

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand All @@ -30,6 +31,7 @@ type Plugin interface {
UnpublishVolume(context.Context, *api.Volume, string) error
AddNode(swarmID, csiID string)
RemoveNode(swarmID string)
Addr() net.Addr
}

// plugin represents an individual CSI controller plugin
Expand All @@ -40,6 +42,7 @@ type plugin struct {

// socket is the unix socket to connect to this plugin at.
socket string
addr net.Addr

// provider is the SecretProvider, which allows retrieving secrets for CSI
// calls.
Expand Down Expand Up @@ -80,6 +83,7 @@ func NewPlugin(p mobyplugin.AddrPlugin, provider SecretProvider) Plugin {
// TODO(dperny): verify that we do not need to include the Network()
// portion of the Addr.
socket: fmt.Sprintf("%s://%s", p.Addr().Network(), p.Addr().String()),
addr: p.Addr(),
provider: provider,
swarmToCSI: map[string]string{},
csiToSwarm: map[string]string{},
Expand Down Expand Up @@ -341,3 +345,7 @@ func (p *plugin) makeControllerUnpublishVolumeRequest(v *api.Volume, nodeID stri
Secrets: secrets,
}
}

func (p *plugin) Addr() net.Addr {
return p.addr
}