diff --git a/.chloggen/fix-default-opampextension-config.yaml b/.chloggen/fix-default-opampextension-config.yaml new file mode 100644 index 0000000000000..53e19feb7a4a4 --- /dev/null +++ b/.chloggen/fix-default-opampextension-config.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: opampextension + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Set the default value of `ReportsAvailableComponents` to `true` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [40485] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/extension/opampextension/config_test.go b/extension/opampextension/config_test.go index 3a274c325b879..10c9810c897d9 100644 --- a/extension/opampextension/config_test.go +++ b/extension/opampextension/config_test.go @@ -40,8 +40,9 @@ func TestUnmarshalConfig(t *testing.T) { }, InstanceUID: "01BX5ZZKBKACTAV9WEVGEMMVRZ", Capabilities: Capabilities{ - ReportsEffectiveConfig: true, - ReportsHealth: true, + ReportsEffectiveConfig: true, + ReportsHealth: true, + ReportsAvailableComponents: true, }, PPIDPollInterval: 5 * time.Second, }, cfg) @@ -65,8 +66,9 @@ func TestUnmarshalHttpConfig(t *testing.T) { }, InstanceUID: "01BX5ZZKBKACTAV9WEVGEMMVRZ", Capabilities: Capabilities{ - ReportsEffectiveConfig: true, - ReportsHealth: true, + ReportsEffectiveConfig: true, + ReportsHealth: true, + ReportsAvailableComponents: true, }, PPIDPollInterval: 5 * time.Second, }, cfg) diff --git a/extension/opampextension/factory.go b/extension/opampextension/factory.go index 868c3bc85c657..3e4907c95308c 100644 --- a/extension/opampextension/factory.go +++ b/extension/opampextension/factory.go @@ -26,8 +26,9 @@ func createDefaultConfig() component.Config { return &Config{ Server: &OpAMPServer{}, Capabilities: Capabilities{ - ReportsEffectiveConfig: true, - ReportsHealth: true, + ReportsEffectiveConfig: true, + ReportsHealth: true, + ReportsAvailableComponents: true, }, PPIDPollInterval: 5 * time.Second, } diff --git a/extension/opampextension/opamp_agent.go b/extension/opampextension/opamp_agent.go index 79e7272d07555..405b41c9a3f1a 100644 --- a/extension/opampextension/opamp_agent.go +++ b/extension/opampextension/opamp_agent.go @@ -168,6 +168,9 @@ func (o *opampAgent) Start(ctx context.Context, host component.Host) error { if mi, ok := host.(moduleInfo); ok { o.initAvailableComponents(mi.GetModuleInfos()) + } else if o.capabilities.ReportsAvailableComponents { + // init empty availableComponents to not get an error when starting the opampClient + o.initAvailableComponents(service.ModuleInfos{}) } if o.availableComponents != nil {