Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package steampipe for openSUSE:Factory checked in at 2026-11-24 17:02:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/steampipe (Old) and /work/SRC/openSUSE:Factory/.steampipe.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "steampipe" Tue Nov 24 17:02:59 2026 rev:26 rq:1400280 version:2.5.1 Changes: -------- --- /work/SRC/openSUSE:Factory/steampipe/steampipe.changes 2026-11-17 17:24:23.001723212 +0100 +++ /work/SRC/openSUSE:Factory/.steampipe.new.1340718/steampipe.changes 2026-11-24 17:03:03.260068527 +0100 @@ -1,0 +2,10 @@ +Tue Nov 24 10:49:03 UTC 2026 - Felix Niederwanger <[email protected]> + +- Update to version 2.5.1: + * v2.5.1 + * service status crashes when only the plugin manager is running closes #5161 (#5162) + * Share the query cache size limit between plugins by connection count closes #5093 (#5094) + * Remove the workflow that adds issues to the unused tracker board (#5157) + * Restore the steampipe query assertion in the duplicate connection name test (#5153) + +------------------------------------------------------------------- Old: ---- steampipe-2.5.0.obscpio New: ---- steampipe-2.5.1.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ steampipe.spec ++++++ --- /var/tmp/diff_new_pack.DbPulZ/_old 2026-11-24 17:03:07.664255119 +0100 +++ /var/tmp/diff_new_pack.DbPulZ/_new 2026-11-24 17:03:07.665255161 +0100 @@ -17,7 +17,7 @@ Name: steampipe -Version: 2.5.0 +Version: 2.5.1 Release: 0 Summary: Query various APIs and services via SQL language License: AGPL-3.0-only ++++++ _service ++++++ --- /var/tmp/diff_new_pack.DbPulZ/_old 2026-11-24 17:03:07.704256813 +0100 +++ /var/tmp/diff_new_pack.DbPulZ/_new 2026-11-24 17:03:07.707256940 +0100 @@ -2,7 +2,7 @@ <service name="obs_scm" mode="manual"> <param name="url">https://github.com/turbot/steampipe.git</param> <param name="scm">git</param> - <param name="revision">v2.5.0</param> + <param name="revision">v2.5.1</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.DbPulZ/_old 2026-11-24 17:03:07.736258169 +0100 +++ /var/tmp/diff_new_pack.DbPulZ/_new 2026-11-24 17:03:07.742258423 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/turbot/steampipe.git</param> - <param name="changesrevision">1f2f7a9fd070f7e251937c14cce87323817a7f3b</param></service></servicedata> + <param name="changesrevision">7b04c8d63b1cd1ed9efd28a162c04bb153991fa6</param></service></servicedata> (No newline at EOF) ++++++ steampipe-2.5.0.obscpio -> steampipe-2.5.1.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/.github/workflows/31-add-issues-to-pipeling-issue-tracker.yaml new/steampipe-2.5.1/.github/workflows/31-add-issues-to-pipeling-issue-tracker.yaml --- old/steampipe-2.5.0/.github/workflows/31-add-issues-to-pipeling-issue-tracker.yaml 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/.github/workflows/31-add-issues-to-pipeling-issue-tracker.yaml 1970-01-01 01:00:00.000000000 +0100 @@ -1,16 +0,0 @@ -name: Assign Issue to Project - -on: - issues: - types: [opened] - -permissions: - contents: read - -jobs: - add-to-project: - uses: turbot/steampipe-workflows/.github/workflows/assign-issue-to-pipeling-issue-tracker.yml@main - with: - issue_number: ${{ github.event.issue.number }} - repository: ${{ github.repository }} - secrets: inherit \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/CHANGELOG.md new/steampipe-2.5.1/CHANGELOG.md --- old/steampipe-2.5.0/CHANGELOG.md 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/CHANGELOG.md 2026-11-17 16:38:11.000000000 +0100 @@ -1,3 +1,8 @@ +## v2.5.1 [2026-11-17] +_Bug fixes_ +- Share the query cache size limit between plugins by connection count instead of giving the full `cache_max_size_mb` to every plugin, and make `STEAMPIPE_CACHE_MAX_SIZE_MB` take effect. ([#5093](https://github.com/turbot/steampipe/issues/5093)) +- Fix `steampipe service status` crashing when only the plugin manager is running, and make `steampipe service stop` clear a leftover plugin manager. ([#5161](https://github.com/turbot/steampipe/issues/5161)) + ## v2.5.0 [2026-11-13] _Whats new_ - Update the embedded PostgreSQL to `14.24.0`. A same-major upgrade now keeps your existing data folder, and the upgrade carries over the newest older database. ([#4961](https://github.com/turbot/steampipe/issues/4961), [#5103](https://github.com/turbot/steampipe/issues/5103)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/cmd/service.go new/steampipe-2.5.1/cmd/service.go --- old/steampipe-2.5.0/cmd/service.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/cmd/service.go 2026-11-17 16:38:11.000000000 +0100 @@ -460,6 +460,11 @@ } if dbState == nil { + // the database is down, but the plugin manager may still be running + if err := pluginmanager.Stop(); err != nil { + exitCode = constants.ExitCodeServiceStopFailure + error_helpers.FailOnErrorWithMessage(err, "could not stop the plugin manager") + } fmt.Println("Steampipe service is not running.") //nolint:forbidigo // acceptable return } @@ -577,7 +582,11 @@ } func printStatus(ctx context.Context, dbState *db_local.RunningDBInstanceInfo, pmState *pluginmanager.State, alreadyRunning bool) { - if dbState == nil && !pmState.Running { + if dbState == nil { + if pmState.Running { + fmt.Printf("The database is not running, but the plugin manager is still running.\nTo clean up, run %s\n", pconstants.Bold("steampipe service stop")) //nolint:forbidigo // acceptable + return + } fmt.Println("Service is not running") //nolint:forbidigo // acceptable return } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/cmd/service_test.go new/steampipe-2.5.1/cmd/service_test.go --- old/steampipe-2.5.0/cmd/service_test.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/cmd/service_test.go 2026-11-17 16:38:11.000000000 +0100 @@ -1,13 +1,17 @@ package cmd import ( + "context" "fmt" + "io" "os" "os/exec" + "strings" "testing" psutils "github.com/shirou/gopsutil/process" "github.com/turbot/steampipe/v2/pkg/db/db_local" + "github.com/turbot/steampipe/v2/pkg/pluginmanager" ) func TestParseServiceCmdline_EmptyCmdline(t *testing.T) { @@ -87,3 +91,39 @@ t.Errorf("rows = %v, want none", rows) } } + +func captureStdout(t *testing.T, f func()) string { + t.Helper() + orig := os.Stdout + r, w, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + os.Stdout = w + defer func() { os.Stdout = orig }() + f() + _ = w.Close() + out, err := io.ReadAll(r) + if err != nil { + t.Fatal(err) + } + return string(out) +} + +func TestPrintStatus_NilDbStatePluginManagerRunning(t *testing.T) { + out := captureStdout(t, func() { + printStatus(context.Background(), nil, &pluginmanager.State{Running: true}, false) + }) + if !strings.Contains(out, "plugin manager") || !strings.Contains(out, "steampipe service stop") { + t.Errorf("output = %q, want a message that the plugin manager is still running and to run `steampipe service stop`", out) + } +} + +func TestPrintStatus_NilDbStatePluginManagerStopped(t *testing.T) { + out := captureStdout(t, func() { + printStatus(context.Background(), nil, &pluginmanager.State{Running: false}, false) + }) + if !strings.Contains(out, "Service is not running") { + t.Errorf("output = %q, want %q", out, "Service is not running") + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/pkg/cmdconfig/viper.go new/steampipe-2.5.1/pkg/cmdconfig/viper.go --- old/steampipe-2.5.0/pkg/cmdconfig/viper.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/pkg/cmdconfig/viper.go 2026-11-17 16:38:11.000000000 +0100 @@ -181,6 +181,7 @@ constants.EnvDashboardStartTimeout: {[]string{pconstants.ArgDashboardStartTimeout}, Int}, constants.EnvCacheTTL: {[]string{pconstants.ArgCacheTtl}, Int}, constants.EnvCacheMaxTTL: {[]string{pconstants.ArgCacheMaxTtl}, Int}, + constants.EnvCacheMaxSize: {[]string{pconstants.ArgMaxCacheSizeMb}, Int}, constants.EnvMemoryMaxMb: {[]string{pconstants.ArgMemoryMaxMb}, Int}, constants.EnvMemoryMaxMbPlugin: {[]string{pconstants.ArgMemoryMaxMbPlugin}, Int}, constants.EnvPluginStartTimeout: {[]string{pconstants.ArgPluginStartTimeout}, Int}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/pkg/cmdconfig/viper_test.go new/steampipe-2.5.1/pkg/cmdconfig/viper_test.go --- old/steampipe-2.5.0/pkg/cmdconfig/viper_test.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/pkg/cmdconfig/viper_test.go 2026-11-17 16:38:11.000000000 +0100 @@ -678,3 +678,31 @@ }) } } + +// STEAMPIPE_CACHE_MAX_SIZE_MB sets the same value as options "database" { cache_max_size_mb }, +// and takes precedence over it, as STEAMPIPE_CACHE_MAX_TTL does for cache_max_ttl +func TestSetDefaultsFromEnv_CacheEnvVarsOverrideDatabaseOptions(t *testing.T) { + tests := []struct { + envVar string + key string + }{ + {envVar: constants.EnvCacheMaxTTL, key: pconstants.ArgCacheMaxTtl}, + {envVar: constants.EnvCacheMaxSize, key: pconstants.ArgMaxCacheSizeMb}, + } + for _, tt := range tests { + t.Run(tt.envVar, func(t *testing.T) { + viper.Reset() + defer viper.Reset() + + // the value from the config file, as initGlobalConfig sets it + SetDefaultsFromConfig(map[string]interface{}{tt.key: 250}) + // then the env var + t.Setenv(tt.envVar, "1000") + setDefaultsFromEnv() + + if got := viper.GetInt64(tt.key); got != 1000 { + t.Errorf("%s=1000 with a config value of 250: expected %s to be 1000, got %d", tt.envVar, tt.key, got) + } + }) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/pkg/pluginmanager_service/message_server_test.go new/steampipe-2.5.1/pkg/pluginmanager_service/message_server_test.go --- old/steampipe-2.5.0/pkg/pluginmanager_service/message_server_test.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/pkg/pluginmanager_service/message_server_test.go 2026-11-17 16:38:11.000000000 +0100 @@ -182,7 +182,6 @@ // Perform various plugin manager operations pm.populatePluginConnectionConfigs() - pm.setPluginCacheSizeMap() pm.nonAggregatorConnectionCount() // Message server should still be accessible diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/pkg/pluginmanager_service/plugin_manager.go new/steampipe-2.5.1/pkg/pluginmanager_service/plugin_manager.go --- old/steampipe-2.5.0/pkg/pluginmanager_service/plugin_manager.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/pkg/pluginmanager_service/plugin_manager.go 2026-11-17 16:38:11.000000000 +0100 @@ -6,7 +6,6 @@ "log" "os" "os/exec" - "strconv" "strings" "sync" "time" @@ -48,8 +47,6 @@ // map of connection configs, keyed by connection name // this is populated at startup and updated when a connection config change is detected connectionConfigMap connection.ConnectionConfigMap - // map of max cache size, keyed by plugin instance - pluginCacheSizeMap map[string]int64 // mut protects concurrent access to plugin manager state (runningPluginMap, connectionConfigMap, etc.) // @@ -114,8 +111,6 @@ // populate plugin connection config map pluginManager.populatePluginConnectionConfigs() - // determine cache size for each plugin - pluginManager.setPluginCacheSizeMap() // create a connection pool to connection refresh // in testing, a size of 20 seemed optimal @@ -635,7 +630,7 @@ // if this plugin supports setting cache options, do so if supportedOperations.SetCacheOptions { - err = m.setCacheOptions(pluginClient) + err = m.setCacheOptions(pluginInstance, pluginClient) if err != nil { log.Printf("[WARN] failed to set cache options for %s: %s", pluginName, err.Error()) return nil, err @@ -678,35 +673,30 @@ } } -// populate map of connection configs for each plugin -func (m *PluginManager) setPluginCacheSizeMap() { - m.pluginCacheSizeMap = make(map[string]int64, len(m.pluginConnectionConfigMap)) - - // read the env var setting cache size - maxCacheSizeMb, _ := strconv.Atoi(os.Getenv(constants.EnvCacheMaxSize)) +// pluginCacheSizeMb returns the query cache size for a plugin instance. +// All plugins share one total (cache_max_size_mb or STEAMPIPE_CACHE_MAX_SIZE_MB), in proportion +// to their number of connections in the current connection config. Aggregators do not count. +// A total of 0 means no limit, so the size is 0. Otherwise the size is at least 1 MB. +func (m *PluginManager) pluginCacheSizeMb(pluginInstance string) int64 { + totalMb := viper.GetInt64(pconstants.ArgMaxCacheSizeMb) + if totalMb <= 0 { + return 0 + } - // get total connection count for this pluginInstance (excluding aggregators) + m.mut.RLock() + numPluginConnections := nonAggregatorConnectionCount(m.pluginConnectionConfigMap[pluginInstance]) numConnections := m.nonAggregatorConnectionCount() + m.mut.RUnlock() - log.Printf("[TRACE] PluginManager setPluginCacheSizeMap: %d %s.", numConnections, utils.Pluralize("connection", numConnections)) - log.Printf("[TRACE] Total cache size %dMb", maxCacheSizeMb) - - for pluginInstance, connections := range m.pluginConnectionConfigMap { - var size int64 = 0 - // if no max size is set, just set all plugins to zero (unlimited) - if maxCacheSizeMb > 0 { - // get connection count for this pluginInstance (excluding aggregators) - numPluginConnections := nonAggregatorConnectionCount(connections) - size = int64(float64(numPluginConnections) / float64(numConnections) * float64(maxCacheSizeMb)) - // make this at least 1 Mb (as zero means unlimited) - if size == 0 { - size = 1 - } - log.Printf("[INFO] Plugin '%s', %d %s, max cache size %dMb", pluginInstance, numPluginConnections, utils.Pluralize("connection", numPluginConnections), size) - } - - m.pluginCacheSizeMap[pluginInstance] = size + var size int64 + if numConnections > 0 { + size = totalMb * int64(numPluginConnections) / int64(numConnections) } + // zero means no limit, so make this at least 1 Mb + size = max(size, 1) + + log.Printf("[INFO] Plugin '%s', %d of %d %s, max cache size %dMb of %dMb", pluginInstance, numPluginConnections, numConnections, utils.Pluralize("connection", numConnections), size, totalMb) + return size } func (m *PluginManager) notifyNewDynamicSchemas(pluginClient *sdkgrpc.PluginClient, exemplarConnectionConfig *sdkproto.ConnectionConfig, connectionNames []string) error { @@ -804,18 +794,18 @@ // if plugin _does not_ support setting the cache options separately, pass the max size now // (if it does support SetCacheOptions, it will be called after we return) if !supportedOperations.SetCacheOptions { - req.MaxCacheSizeMb = m.pluginCacheSizeMap[pluginInstance] + req.MaxCacheSizeMb = m.pluginCacheSizeMb(pluginInstance) } _, err := pluginClient.SetAllConnectionConfigs(req) return err } -func (m *PluginManager) setCacheOptions(pluginClient *sdkgrpc.PluginClient) error { +func (m *PluginManager) setCacheOptions(pluginInstance string, pluginClient *sdkgrpc.PluginClient) error { req := &sdkproto.SetCacheOptionsRequest{ Enabled: viper.GetBool(pconstants.ArgServiceCacheEnabled), Ttl: viper.GetInt64(pconstants.ArgCacheMaxTtl), - MaxSizeMb: viper.GetInt64(pconstants.ArgMaxCacheSizeMb), + MaxSizeMb: m.pluginCacheSizeMb(pluginInstance), } _, err := pluginClient.SetCacheOptions(req) return err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/pkg/pluginmanager_service/plugin_manager_cache_size_test.go new/steampipe-2.5.1/pkg/pluginmanager_service/plugin_manager_cache_size_test.go --- old/steampipe-2.5.0/pkg/pluginmanager_service/plugin_manager_cache_size_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/steampipe-2.5.1/pkg/pluginmanager_service/plugin_manager_cache_size_test.go 2026-11-17 16:38:11.000000000 +0100 @@ -0,0 +1,286 @@ +package pluginmanager_service + +import ( + "context" + "fmt" + "sync" + "testing" + "time" + + "github.com/hashicorp/go-hclog" + goplugin "github.com/hashicorp/go-plugin" + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + sdkproto "github.com/turbot/steampipe-plugin-sdk/v6/grpc/proto" + sdkshared "github.com/turbot/steampipe-plugin-sdk/v6/grpc/shared" + sdkplugin "github.com/turbot/steampipe-plugin-sdk/v6/plugin" + "github.com/turbot/steampipe/v2/pkg/connection" + "github.com/turbot/steampipe/v2/pkg/options" + pb "github.com/turbot/steampipe/v2/pkg/pluginmanager_service/grpc/proto" +) + +// The query cache size limit is one total for all plugins. Each plugin gets a share of the +// total, in proportion to its number of connections (aggregators are not counted). +// +// These tests start fake plugins in this process and initialize them with the real +// PluginManager.initializePlugin, so they check the cache size each plugin receives. + +// fakePlugin is a plugin server that records the requests that set its cache size. +// It implements only the calls that the plugin manager makes when it initializes a plugin. +type fakePlugin struct { + sdkshared.WrapperPluginServer + supportsSetCacheOptions bool + + mut sync.Mutex + allConnectionConfigs *sdkproto.SetAllConnectionConfigsRequest + cacheOptions *sdkproto.SetCacheOptionsRequest +} + +func (p *fakePlugin) GetSupportedOperations(*sdkproto.GetSupportedOperationsRequest) (*sdkproto.GetSupportedOperationsResponse, error) { + return &sdkproto.GetSupportedOperationsResponse{ + MultipleConnections: true, + SetCacheOptions: p.supportsSetCacheOptions, + }, nil +} + +func (p *fakePlugin) SetAllConnectionConfigs(req *sdkproto.SetAllConnectionConfigsRequest) (*sdkproto.SetConnectionConfigResponse, error) { + p.mut.Lock() + defer p.mut.Unlock() + p.allConnectionConfigs = req + return &sdkproto.SetConnectionConfigResponse{}, nil +} + +func (p *fakePlugin) SetCacheOptions(req *sdkproto.SetCacheOptionsRequest) (*sdkproto.SetCacheOptionsResponse, error) { + p.mut.Lock() + defer p.mut.Unlock() + p.cacheOptions = req + return &sdkproto.SetCacheOptionsResponse{}, nil +} + +func (p *fakePlugin) GetSchema(*sdkproto.GetSchemaRequest) (*sdkproto.GetSchemaResponse, error) { + return &sdkproto.GetSchemaResponse{Schema: &sdkproto.Schema{Mode: sdkplugin.SchemaModeStatic}}, nil +} + +// received returns the requests the plugin received +func (p *fakePlugin) received() (*sdkproto.SetAllConnectionConfigsRequest, *sdkproto.SetCacheOptionsRequest) { + p.mut.Lock() + defer p.mut.Unlock() + return p.allConnectionConfigs, p.cacheOptions +} + +// cacheSizeMb returns the cache size the plugin received: from SetCacheOptions if the plugin +// supports it, otherwise from SetAllConnectionConfigs +func (p *fakePlugin) cacheSizeMb(t *testing.T) int64 { + t.Helper() + allConnectionConfigs, cacheOptions := p.received() + require.NotNil(t, allConnectionConfigs, "plugin did not receive SetAllConnectionConfigs") + if !p.supportsSetCacheOptions { + require.Nil(t, cacheOptions, "plugin without SetCacheOptions support received SetCacheOptions") + return allConnectionConfigs.MaxCacheSizeMb + } + // the plugin manager sends -1 in SetAllConnectionConfigs, so that the plugin waits for SetCacheOptions + require.Equal(t, int64(-1), allConnectionConfigs.MaxCacheSizeMb) + require.NotNil(t, cacheOptions, "plugin did not receive SetCacheOptions") + return cacheOptions.MaxSizeMb +} + +// serveFakePlugin serves impl in this process and returns a started client for it, +// the way startPluginProcess returns a started client for a plugin process +func serveFakePlugin(t *testing.T, pluginName string, impl *fakePlugin) *goplugin.Client { + t.Helper() + + ctx, cancel := context.WithCancel(context.Background()) + reattachCh := make(chan *goplugin.ReattachConfig, 1) + closeCh := make(chan struct{}) + go goplugin.Serve(&goplugin.ServeConfig{ + HandshakeConfig: sdkshared.Handshake, + Plugins: map[string]goplugin.Plugin{pluginName: &sdkshared.WrapperPlugin{Impl: impl}}, + GRPCServer: goplugin.DefaultGRPCServer, + Logger: hclog.NewNullLogger(), + Test: &goplugin.ServeTestConfig{Context: ctx, ReattachConfigCh: reattachCh, CloseCh: closeCh}, + }) + + var reattach *goplugin.ReattachConfig + select { + case reattach = <-reattachCh: + case <-time.After(10 * time.Second): + cancel() + t.Fatal("fake plugin did not start") + } + + client := goplugin.NewClient(&goplugin.ClientConfig{ + HandshakeConfig: sdkshared.Handshake, + Plugins: map[string]goplugin.Plugin{pluginName: &sdkshared.WrapperPlugin{}}, + Reattach: reattach, + AllowedProtocols: []goplugin.Protocol{goplugin.ProtocolGRPC}, + Logger: hclog.NewNullLogger(), + }) + t.Cleanup(func() { + client.Kill() + cancel() + <-closeCh + }) + _, err := client.Start() + require.NoError(t, err) + return client +} + +// startFakePlugin starts a fake plugin for a plugin instance and initializes it with all the +// connections the plugin manager has for that instance, as startPlugin does +func startFakePlugin(t *testing.T, pm *PluginManager, pluginInstance string, supportsSetCacheOptions bool) *fakePlugin { + t.Helper() + connectionConfigs := pm.pluginConnectionConfigMap[pluginInstance] + require.NotEmpty(t, connectionConfigs, "no connections for plugin instance %s", pluginInstance) + + impl := &fakePlugin{supportsSetCacheOptions: supportsSetCacheOptions} + client := serveFakePlugin(t, connectionConfigs[0].Plugin, impl) + _, err := pm.initializePlugin(connectionConfigs, client, &pb.GetRequest{}) + require.NoError(t, err) + return impl +} + +// setDatabaseOptions sets viper from options "database" { cache = true, cache_max_ttl = 300, cache_max_size_mb = ... } +// in the same way as the config loader. A nil cacheMaxSizeMb leaves cache_max_size_mb unset. +func setDatabaseOptions(t *testing.T, cacheMaxSizeMb *int) { + t.Helper() + viper.Reset() + t.Cleanup(viper.Reset) + + cacheEnabled := true + cacheMaxTtl := 300 + databaseOptions := &options.Database{Cache: &cacheEnabled, CacheMaxTtl: &cacheMaxTtl, CacheMaxSizeMb: cacheMaxSizeMb} + for k, v := range databaseOptions.ConfigMap() { + viper.SetDefault(k, v) + } +} + +// connectionCounts is the number of (non aggregator) connections for each plugin instance +type connectionCounts map[string]int + +// buildConnectionConfigMap builds a connection config map with the given number of connections +// for each plugin instance, plus one aggregator connection for each plugin instance +func buildConnectionConfigMap(counts connectionCounts) connection.ConnectionConfigMap { + configMap := make(connection.ConnectionConfigMap) + for pluginInstance, count := range counts { + var children []string + for i := 1; i <= count; i++ { + name := fmt.Sprintf("%s_%d", pluginInstance, i) + configMap[name] = newTestConnectionConfig(pluginInstance, pluginInstance, name) + children = append(children, name) + } + aggregator := newTestConnectionConfig(pluginInstance, pluginInstance, pluginInstance+"_all") + aggregator.ChildConnections = children + configMap[aggregator.Connection] = aggregator + } + return configMap +} + +func newCacheTestPluginManager(t *testing.T, counts connectionCounts) *PluginManager { + t.Helper() + pm := newTestPluginManager(t) + pm.connectionConfigMap = buildConnectionConfigMap(counts) + pm.populatePluginConnectionConfigs() + return pm +} + +// cacheSizesMb starts a fake plugin for each plugin instance and returns the cache size each one received +func cacheSizesMb(t *testing.T, pm *PluginManager, supportsSetCacheOptions bool, pluginInstances ...string) map[string]int64 { + t.Helper() + sizes := make(map[string]int64) + for _, pluginInstance := range pluginInstances { + sizes[pluginInstance] = startFakePlugin(t, pm, pluginInstance, supportsSetCacheOptions).cacheSizeMb(t) + } + return sizes +} + +// cacheSizeTestPaths are the two ways the plugin manager sends a plugin its cache size +var cacheSizeTestPaths = []struct { + name string + supportsSetCacheOptions bool +}{ + {name: "SetCacheOptions", supportsSetCacheOptions: true}, + {name: "SetAllConnectionConfigs (plugin without SetCacheOptions)", supportsSetCacheOptions: false}, +} + +// Worked example: a total of 900 MB, with aws 10 connections, gcp 5 and net 1 (16 in all). +// aws gets 900 x 10/16 = 562, gcp 900 x 5/16 = 281, net 900 x 1/16 = 56. +// The aggregator connections do not count. +func TestInitializePlugin_CacheSizeIsShareOfConfigTotal(t *testing.T) { + for _, path := range cacheSizeTestPaths { + t.Run(path.name, func(t *testing.T) { + total := 900 + setDatabaseOptions(t, &total) + pm := newCacheTestPluginManager(t, connectionCounts{"aws": 10, "gcp": 5, "net": 1}) + + sizes := cacheSizesMb(t, pm, path.supportsSetCacheOptions, "aws", "gcp", "net") + + assert.Equal(t, map[string]int64{"aws": 562, "gcp": 281, "net": 56}, sizes) + assert.LessOrEqual(t, sizes["aws"]+sizes["gcp"]+sizes["net"], int64(total), "the shares must not add up to more than the total") + }) + } +} + +// The other cache options are sent unchanged +func TestInitializePlugin_CacheOptionsKeepTtlAndEnabled(t *testing.T) { + total := 900 + setDatabaseOptions(t, &total) + pm := newCacheTestPluginManager(t, connectionCounts{"aws": 1}) + + _, cacheOptions := startFakePlugin(t, pm, "aws", true).received() + + require.NotNil(t, cacheOptions) + assert.True(t, cacheOptions.Enabled) + assert.Equal(t, int64(300), cacheOptions.Ttl) +} + +// A share is never less than 1 MB, because 0 means no limit. +// A total of 5 MB, with aws 9 connections and net 1: aws gets 5 x 9/10 = 4, net gets 5 x 1/10 = 0, so 1. +func TestInitializePlugin_CacheShareIsAtLeastOneMb(t *testing.T) { + for _, path := range cacheSizeTestPaths { + t.Run(path.name, func(t *testing.T) { + total := 5 + setDatabaseOptions(t, &total) + pm := newCacheTestPluginManager(t, connectionCounts{"aws": 9, "net": 1}) + + sizes := cacheSizesMb(t, pm, path.supportsSetCacheOptions, "aws", "net") + + assert.Equal(t, map[string]int64{"aws": 4, "net": 1}, sizes) + }) + } +} + +// With no total, or a total of 0, there is no limit: every plugin gets 0 +func TestInitializePlugin_NoCacheTotalMeansNoLimit(t *testing.T) { + zero := 0 + totals := map[string]*int{"cache_max_size_mb not set": nil, "cache_max_size_mb = 0": &zero} + for totalName, total := range totals { + for _, path := range cacheSizeTestPaths { + t.Run(totalName+"/"+path.name, func(t *testing.T) { + setDatabaseOptions(t, total) + pm := newCacheTestPluginManager(t, connectionCounts{"aws": 10, "net": 1}) + + sizes := cacheSizesMb(t, pm, path.supportsSetCacheOptions, "aws", "net") + + assert.Equal(t, map[string]int64{"aws": 0, "net": 0}, sizes) + }) + } + } +} + +// A plugin gets its share from the connections that exist when it starts. +// The plugin manager starts with aws 1 connection and net 1, and starts aws: 900 x 1/2 = 450. +// Then 2 aws connections are added (aws 3, net 1), and net starts: 900 x 1/4 = 225. +func TestInitializePlugin_CacheShareUsesConnectionsWhenPluginStarts(t *testing.T) { + total := 900 + setDatabaseOptions(t, &total) + pm := newCacheTestPluginManager(t, connectionCounts{"aws": 1, "net": 1}) + + aws := startFakePlugin(t, pm, "aws", true) + assert.Equal(t, int64(450), aws.cacheSizeMb(t)) + + pm.OnConnectionConfigChanged(context.Background(), buildConnectionConfigMap(connectionCounts{"aws": 3, "net": 1}), pm.plugins) + + net := startFakePlugin(t, pm, "net", true) + assert.Equal(t, int64(225), net.cacheSizeMb(t)) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/pkg/pluginmanager_service/plugin_manager_test.go new/steampipe-2.5.1/pkg/pluginmanager_service/plugin_manager_test.go --- old/steampipe-2.5.0/pkg/pluginmanager_service/plugin_manager_test.go 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/pkg/pluginmanager_service/plugin_manager_test.go 2026-11-17 16:38:11.000000000 +0100 @@ -29,7 +29,6 @@ runningPluginMap: make(map[string]*runningPlugin), pluginConnectionConfigMap: make(map[string][]*sdkproto.ConnectionConfig), connectionConfigMap: make(connection.ConnectionConfigMap), - pluginCacheSizeMap: make(map[string]int64), plugins: make(connection.PluginMap), userLimiters: make(connection.PluginLimiterMap), pluginLimiters: make(connection.PluginLimiterMap), @@ -359,26 +358,6 @@ wg.Wait() } -// Test 10: Plugin Cache Size Map - -func TestPluginManager_SetPluginCacheSizeMap_NoCacheLimit(t *testing.T) { - pm := newTestPluginManager(t) - - config1 := newTestConnectionConfig("plugin1", "instance1", "conn1") - config2 := newTestConnectionConfig("plugin2", "instance2", "conn2") - - pm.pluginConnectionConfigMap = map[string][]*sdkproto.ConnectionConfig{ - "instance1": {config1}, - "instance2": {config2}, - } - - pm.setPluginCacheSizeMap() - - // When no max size is set, all plugins should have size 0 (unlimited) - assert.Equal(t, int64(0), pm.pluginCacheSizeMap["instance1"]) - assert.Equal(t, int64(0), pm.pluginCacheSizeMap["instance2"]) -} - // Test 11: NonAggregatorConnectionCount func TestPluginManager_NonAggregatorConnectionCount(t *testing.T) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/tests/acceptance/test_data/source_files/cache_max_size_300.spc new/steampipe-2.5.1/tests/acceptance/test_data/source_files/cache_max_size_300.spc --- old/steampipe-2.5.0/tests/acceptance/test_data/source_files/cache_max_size_300.spc 1970-01-01 01:00:00.000000000 +0100 +++ new/steampipe-2.5.1/tests/acceptance/test_data/source_files/cache_max_size_300.spc 2026-11-17 16:38:11.000000000 +0100 @@ -0,0 +1,3 @@ +options "database" { + cache_max_size_mb = 300 +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/tests/acceptance/test_data/source_files/cache_size_chaos2.spc new/steampipe-2.5.1/tests/acceptance/test_data/source_files/cache_size_chaos2.spc --- old/steampipe-2.5.0/tests/acceptance/test_data/source_files/cache_size_chaos2.spc 1970-01-01 01:00:00.000000000 +0100 +++ new/steampipe-2.5.1/tests/acceptance/test_data/source_files/cache_size_chaos2.spc 2026-11-17 16:38:11.000000000 +0100 @@ -0,0 +1,3 @@ +connection "chaos2" { + plugin = "chaos" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/tests/acceptance/test_files/cache.bats new/steampipe-2.5.1/tests/acceptance/test_files/cache.bats --- old/steampipe-2.5.0/tests/acceptance/test_files/cache.bats 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/tests/acceptance/test_files/cache.bats 2026-11-17 16:38:11.000000000 +0100 @@ -193,6 +193,96 @@ assert_not_equal "$unique1" "$unique3" } +# The query cache size limit is one total for all plugins. Each plugin gets a share of the total, +# in proportion to its number of connections. With the chaos2 connection added, chaos has 2 +# connections (chaos, chaos2) and chaosdynamic has 1. So for a total of 300 MB, chaos gets +# 300 x 2/3 = 200 MB and chaosdynamic gets 300 x 1/3 = 100 MB. + +# count the lines in the plugin logs +function plugin_log_line_count() { + cat $STEAMPIPE_INSTALL_DIR/logs/plugin-*.log 2>/dev/null | wc -l | tr -d ' ' +} + +# print the query cache size(s) that plugin $1 logged when it started, after line $2 of the plugin logs +function cache_size_logged_by() { + cat $STEAMPIPE_INSTALL_DIR/logs/plugin-*.log 2>/dev/null | tail -n +$(( $2 + 1 )) | grep -F "steampipe-plugin-$1.plugin:" | grep -o 'query cache created, max size [0-9]*Mb' | grep -o '[0-9][0-9]*' | sort -u +} + +# start both plugins with one query +function query_both_plugins() { + steampipe query "select (select count(*) from chaos2.chaos_all_column_types) as chaos_rows, (select count(*) from chaosdynamic.test1) as chaosdynamic_rows" +} + +@test "cache_max_size_mb in database options is one total, shared by the plugins by connection count" { + export STEAMPIPE_LOG=info + cp $SRC_DATA_DIR/cache_size_chaos2.spc $STEAMPIPE_INSTALL_DIR/config/cache_size_chaos2.spc + cp $SRC_DATA_DIR/cache_max_size_300.spc $STEAMPIPE_INSTALL_DIR/config/cache_max_size_300.spc + ls $STEAMPIPE_INSTALL_DIR/config + + start=$(plugin_log_line_count) + run query_both_plugins + echo $output + queried=$status + + chaos=$(cache_size_logged_by chaos $start) + chaosdynamic=$(cache_size_logged_by chaosdynamic $start) + echo "chaos: $chaos, chaosdynamic: $chaosdynamic" + + rm -f $STEAMPIPE_INSTALL_DIR/config/cache_size_chaos2.spc + rm -f $STEAMPIPE_INSTALL_DIR/config/cache_max_size_300.spc + + assert_equal "$queried" "0" + assert_equal "$chaos" "200" + assert_equal "$chaosdynamic" "100" +} + +@test "STEAMPIPE_CACHE_MAX_SIZE_MB is one total, shared by the plugins by connection count" { + export STEAMPIPE_LOG=info + cp $SRC_DATA_DIR/cache_size_chaos2.spc $STEAMPIPE_INSTALL_DIR/config/cache_size_chaos2.spc + ls $STEAMPIPE_INSTALL_DIR/config + + start=$(plugin_log_line_count) + export STEAMPIPE_CACHE_MAX_SIZE_MB=300 + run query_both_plugins + echo $output + queried=$status + + chaos=$(cache_size_logged_by chaos $start) + chaosdynamic=$(cache_size_logged_by chaosdynamic $start) + echo "chaos: $chaos, chaosdynamic: $chaosdynamic" + + rm -f $STEAMPIPE_INSTALL_DIR/config/cache_size_chaos2.spc + + assert_equal "$queried" "0" + assert_equal "$chaos" "200" + assert_equal "$chaosdynamic" "100" +} + +@test "STEAMPIPE_CACHE_MAX_SIZE_MB takes precedence over cache_max_size_mb in database options" { + export STEAMPIPE_LOG=info + cp $SRC_DATA_DIR/cache_size_chaos2.spc $STEAMPIPE_INSTALL_DIR/config/cache_size_chaos2.spc + cp $SRC_DATA_DIR/cache_max_size_300.spc $STEAMPIPE_INSTALL_DIR/config/cache_max_size_300.spc + ls $STEAMPIPE_INSTALL_DIR/config + + start=$(plugin_log_line_count) + # a total of 600 MB: chaos gets 600 x 2/3 = 400 MB, chaosdynamic gets 600 x 1/3 = 200 MB + export STEAMPIPE_CACHE_MAX_SIZE_MB=600 + run query_both_plugins + echo $output + queried=$status + + chaos=$(cache_size_logged_by chaos $start) + chaosdynamic=$(cache_size_logged_by chaosdynamic $start) + echo "chaos: $chaos, chaosdynamic: $chaosdynamic" + + rm -f $STEAMPIPE_INSTALL_DIR/config/cache_size_chaos2.spc + rm -f $STEAMPIPE_INSTALL_DIR/config/cache_max_size_300.spc + + assert_equal "$queried" "0" + assert_equal "$chaos" "400" + assert_equal "$chaosdynamic" "200" +} + function teardown_file() { # list running processes ps -ef | grep steampipe diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/steampipe-2.5.0/tests/acceptance/test_files/connection_config.bats new/steampipe-2.5.1/tests/acceptance/test_files/connection_config.bats --- old/steampipe-2.5.0/tests/acceptance/test_files/connection_config.bats 2026-11-13 14:03:16.000000000 +0100 +++ new/steampipe-2.5.1/tests/acceptance/test_files/connection_config.bats 2026-11-17 16:38:11.000000000 +0100 @@ -64,12 +64,9 @@ cp $SRC_DATA_DIR/chaos.json $STEAMPIPE_INSTALL_DIR/config/chaos2.json cp $SRC_DATA_DIR/chaos.json $STEAMPIPE_INSTALL_DIR/config/chaos3.json - # duplicates are skipped with warnings, but the command must still succeed. - # NOTE: exercises the CLI config-loader path only - any command that starts - # the service crashes in the pinned FDW, whose vendored loader still - # hard-errors on duplicates (#5021). Restore the - # `steampipe query` assertion once the FDW vendors the tolerant loader. - run steampipe plugin install chaos + # duplicates are skipped with warnings, but the command must still succeed, + # including a command that starts the service + run steampipe query "select time_col from chaos.chaos_cache_check" # remove the config file rm -f $STEAMPIPE_INSTALL_DIR/config/chaos2.json ++++++ steampipe.obsinfo ++++++ --- /var/tmp/diff_new_pack.DbPulZ/_old 2026-11-24 17:03:08.268280709 +0100 +++ /var/tmp/diff_new_pack.DbPulZ/_new 2026-11-24 17:03:08.272280879 +0100 @@ -1,5 +1,5 @@ name: steampipe -version: 2.5.0 -mtime: 1794574996 -commit: 1f2f7a9fd070f7e251937c14cce87323817a7f3b +version: 2.5.1 +mtime: 1794929891 +commit: 7b04c8d63b1cd1ed9efd28a162c04bb153991fa6 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/steampipe/vendor.tar.gz /work/SRC/openSUSE:Factory/.steampipe.new.1340718/vendor.tar.gz differ: char 116, line 1
