Plugins: Don't start runner ticker for Core plugins (#46964) (#47056)

* Plugins: Don't start runner ticker for Core plugins

* add test

* correct start check in test

(cherry picked from commit 23dde457ef)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-03-30 15:03:35 +02:00
committed by GitHub
co-authored by Will Browne
parent 205421fbbf
commit 13fc39def9
2 changed files with 21 additions and 5 deletions
+5 -3
View File
@@ -362,13 +362,15 @@ func (m *PluginManager) start(ctx context.Context, p *plugins.Plugin) error {
return backendplugin.ErrPluginNotRegistered
}
if p.IsCorePlugin() {
return nil
}
if err := startPluginAndRestartKilledProcesses(ctx, p); err != nil {
return err
}
if !p.IsCorePlugin() {
p.Logger().Debug("Successfully started backend plugin process")
}
p.Logger().Debug("Successfully started backend plugin process")
return nil
}
+16 -2
View File
@@ -242,7 +242,7 @@ func TestPluginManager_Installer(t *testing.T) {
err := pm.loadPlugins(context.Background(), plugins.Core, "test/path")
require.NoError(t, err)
assert.Equal(t, 1, pc.startCount)
assert.Equal(t, 0, pc.startCount)
assert.Equal(t, 0, pc.stopCount)
assert.False(t, pc.exited)
assert.False(t, pc.decommissioned)
@@ -433,6 +433,20 @@ func TestPluginManager_lifecycle_managed(t *testing.T) {
})
})
})
newScenario(t, true, func(t *testing.T, ctx *managerScenarioCtx) {
t.Run("Backend core plugin is registered but not started", func(t *testing.T) {
ctx.plugin.Class = plugins.Core
err := ctx.manager.registerAndStart(context.Background(), ctx.plugin)
require.NoError(t, err)
require.NotNil(t, ctx.plugin)
require.Equal(t, testPluginID, ctx.plugin.ID)
require.Equal(t, 0, ctx.pluginClient.startCount)
testPlugin, exists := ctx.manager.Plugin(context.Background(), testPluginID)
assert.True(t, exists)
require.NotNil(t, testPlugin)
})
})
}
func TestPluginManager_lifecycle_unmanaged(t *testing.T) {
@@ -541,7 +555,7 @@ func newScenario(t *testing.T, managed bool, fn func(t *testing.T, ctx *managerS
manager: manager,
}
ctx.plugin, ctx.pluginClient = createPlugin(testPluginID, "", plugins.Core, managed, true)
ctx.plugin, ctx.pluginClient = createPlugin(testPluginID, "", plugins.External, managed, true)
fn(t, ctx)
}