Skip to content

Commit

Permalink
Merge pull request #3047 from dperny/split-plugins
Browse files Browse the repository at this point in the history
Use two different interfaces for CSI plugins
  • Loading branch information
dperny authored Jan 11, 2022
2 parents 234cb83 + faaed63 commit d67fed1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions agent/csi/plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
const (
// DockerCSIPluginCap is the capability name of the plugins we use with the
// PluginGetter to get only the plugins we need. The full name of the
// plugin interface is "swarm.csiplugin/1.0"
DockerCSIPluginCap = "csiplugin"
// plugin interface is "docker.csinode/1.0". This gets only plugins with
// Node capabilities.
DockerCSIPluginCap = "csinode"
)

// PluginManager manages the multiple CSI plugins that may be in use on the
Expand Down
5 changes: 3 additions & 2 deletions manager/csi/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
const (
// DockerCSIPluginCap is the capability name of the plugins we use with the
// PluginGetter to get only the plugins we need. The full name of the
// plugin interface is "swarm.csiplugin/1.0"
DockerCSIPluginCap = "csiplugin"
// plugin interface is "docker.csicontroller/1.0". This gets only the CSI
// plugins with Controller capability.
DockerCSIPluginCap = "csicontroller"
)

type Manager struct {
Expand Down
12 changes: 6 additions & 6 deletions testutils/fake_plugingetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import (
"github.com/docker/docker/pkg/plugins"
)

// DockerCSIPluginCap is the capability for CSI plugins.
const DockerCSIPluginCap = "csiplugin"
const DockerCSIPluginNodeCap = "csinode"
const DockerCSIPluginControllerCap = "csicontroller"

type FakePluginGetter struct {
Plugins map[string]*FakeCompatPlugin
}

func (f *FakePluginGetter) Get(name, capability string, _ int) (plugingetter.CompatPlugin, error) {
if capability != DockerCSIPluginCap {
if capability != DockerCSIPluginNodeCap && capability != DockerCSIPluginControllerCap {
return nil, fmt.Errorf(
"requested plugin with %s cap, but should only ever request %s",
capability, DockerCSIPluginCap,
"requested plugin with %s cap, but should only ever request %s or %s",
capability, DockerCSIPluginNodeCap, DockerCSIPluginControllerCap,
)
}

Expand All @@ -38,7 +38,7 @@ func (f *FakePluginGetter) GetAllByCap(_ string) ([]plugingetter.CompatPlugin, e
// GetAllManagedPluginsByCap returns all of the fake's plugins. If capability
// is anything other than DockerCSIPluginCap, it returns nothing.
func (f *FakePluginGetter) GetAllManagedPluginsByCap(capability string) []plugingetter.CompatPlugin {
if capability != DockerCSIPluginCap {
if capability != DockerCSIPluginNodeCap && capability != DockerCSIPluginControllerCap {
return nil
}

Expand Down

0 comments on commit d67fed1

Please sign in to comment.