feat(storage): Add support for storage plugins

This commit is contained in:
Louis Ruch authored and Timothy Messier committed 2023-05-31 12:18:12 +00:00
1 parent 9ef94892f4
commit 798a1f952a
17 files changed
+253 -138

No files matched your search

+14 -14
View File
@@ -45,7 +45,7 @@ import (
"github.com/hashicorp/boundary/internal/types/scope"
host_plugin_assets "github.com/hashicorp/boundary/plugins/host"
"github.com/hashicorp/boundary/sdk/pbs/plugin"
external_host_plugins "github.com/hashicorp/boundary/sdk/plugins/host"
external_plugins "github.com/hashicorp/boundary/sdk/plugins"
"github.com/hashicorp/boundary/version"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-secure-stdlib/mlock"
@@ -251,29 +251,30 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
}
}
switch enabledPlugin {
case base.EnabledPluginHostLoopback:
case base.EnabledPluginLoopback:
lp, err := loopback.NewLoopbackPlugin()
if err != nil {
return nil, fmt.Errorf("error creating loopback plugin: %w", err)
}
plg := loopback.NewWrappingPluginHostClient(lp)
opts := []host.Option{
host.WithDescription("Provides an initial loopback host plugin in Boundary"),
host.WithDescription("Provides an initial loopback storage and host plugin in Boundary"),
host.WithPublicId(conf.DevLoopbackPluginId),
}
// TODO(storage): Register loopback as storage supported
if _, err = conf.RegisterHostPlugin(ctx, "loopback", plg, opts...); err != nil {
return nil, err
}
case base.EnabledPluginHostAzure, base.EnabledPluginHostAws:
case base.EnabledPluginHostAzure, base.EnabledPluginAws:
pluginType := strings.ToLower(enabledPlugin.String())
client, cleanup, err := external_host_plugins.CreateHostPlugin(
client, cleanup, err := external_plugins.CreateHostPlugin(
ctx,
pluginType,
external_host_plugins.WithPluginOptions(
external_plugins.WithPluginOptions(
pluginutil.WithPluginExecutionDirectory(conf.RawConfig.Plugins.ExecutionDir),
pluginutil.WithPluginsFilesystem(host_plugin_assets.HostPluginPrefix, host_plugin_assets.FileSystem()),
),
external_host_plugins.WithLogger(pluginLogger.Named(pluginType)),
external_plugins.WithLogger(pluginLogger.Named(pluginType)),
)
if err != nil {
return nil, fmt.Errorf("error creating %s host plugin: %w", pluginType, err)
@@ -337,14 +338,13 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
}
// TODO: Allow setting run jobs limit from config
schedulerOpts := []scheduler.Option{scheduler.WithRunJobsLimit(-1)}
if sche := c.conf.RawConfig.Controller.Scheduler; sche != nil {
if sche.JobRunIntervalDuration > 0 {
schedulerOpts = append(schedulerOpts, scheduler.WithRunJobsInterval(sche.JobRunIntervalDuration))
}
if sche.MonitorIntervalDuration > 0 {
schedulerOpts = append(schedulerOpts, scheduler.WithMonitorInterval(sche.MonitorIntervalDuration))
}
if c.conf.RawConfig.Controller.Scheduler.JobRunIntervalDuration > 0 {
schedulerOpts = append(schedulerOpts, scheduler.WithRunJobsInterval(c.conf.RawConfig.Controller.Scheduler.JobRunIntervalDuration))
}
if c.conf.RawConfig.Controller.Scheduler.MonitorIntervalDuration > 0 {
schedulerOpts = append(schedulerOpts, scheduler.WithMonitorInterval(c.conf.RawConfig.Controller.Scheduler.MonitorIntervalDuration))
}
c.scheduler, err = scheduler.New(c.conf.RawConfig.Controller.Name, jobRepoFn, schedulerOpts...)
if err != nil {
return nil, fmt.Errorf("error creating new scheduler: %w", err)
@@ -255,7 +255,7 @@ func TestController_NewPluginsConfig(t *testing.T) {
initialConfig.Plugins.ExecutionDir = tmpDir
conf := TestControllerConfig(t, ctx, tc, &TestControllerOpts{Config: initialConfig})
conf.EnabledPlugins = []base.EnabledPlugin{
base.EnabledPluginHostAws,
base.EnabledPluginAws,
base.EnabledPluginHostAzure,
}
+1 -5
View File
@@ -614,7 +614,7 @@ func TestControllerConfig(t testing.TB, ctx context.Context, tc *TestController,
tc.b.DevUnprivilegedOidcAccountId = DefaultTestUnprivilegedOidcAccountId
tc.b.DevLoopbackPluginId = DefaultTestPluginId
tc.b.EnabledPlugins = append(tc.b.EnabledPlugins, base.EnabledPluginHostLoopback)
tc.b.EnabledPlugins = append(tc.b.EnabledPlugins, base.EnabledPluginLoopback)
// Start a logger
tc.b.Logger = opts.Logger
@@ -632,10 +632,6 @@ func TestControllerConfig(t testing.TB, ctx context.Context, tc *TestController,
if opts.Config.Controller.Name == "" {
require.NoError(t, opts.Config.Controller.InitNameIfEmpty())
}
if opts.Config.Controller.Scheduler == nil {
opts.Config.Controller.Scheduler = new(config.Scheduler)
}
opts.Config.Controller.Scheduler.JobRunIntervalDuration = opts.SchedulerRunJobInterval
if opts.EnableEventing {