Skip to content

Commit

Permalink
Merge pull request #3181 from blib/master
Browse files Browse the repository at this point in the history
fix CSI plugin load issue (plugin does not implement PluginAddr)
  • Loading branch information
dperny authored Oct 17, 2024
2 parents 376321b + 45a0c5c commit e8ecf83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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
}

0 comments on commit e8ecf83

Please sign in to comment.