From 5faf20d15a24a82a97d6f557f04d6df21f0e0b69 Mon Sep 17 00:00:00 2001 From: William Dumont Date: Fri, 15 Nov 2024 10:58:13 +0100 Subject: [PATCH 1/2] update broker config --- receiver/solacereceiver/README.md | 8 ++--- receiver/solacereceiver/config.go | 6 +++- receiver/solacereceiver/config_test.go | 35 ++++++++++++++++++++ receiver/solacereceiver/testdata/config.yaml | 12 +++++++ 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/receiver/solacereceiver/README.md b/receiver/solacereceiver/README.md index 7e1edd67b28a..20b12781858d 100644 --- a/receiver/solacereceiver/README.md +++ b/receiver/solacereceiver/README.md @@ -19,7 +19,7 @@ To get started with the Solace receiver, a telemetry queue and authentication de ```yaml receivers: solace: - broker: [localhost:5671] + broker: localhost:5671 auth: sasl_plain: username: otel @@ -63,7 +63,7 @@ Simple single node configuration with SASL plain authentication (TLS enabled by ```yaml receivers: solace: - broker: [localhost:5671] + broker: localhost:5671 auth: sasl_plain: username: otel @@ -80,7 +80,7 @@ High availability setup with SASL plain authentication (TLS enabled by default) ```yaml receivers: solace/primary: - broker: [myHost-primary:5671] + broker: myHost-primary:5671 auth: sasl_plain: username: otel @@ -88,7 +88,7 @@ receivers: queue: queue://#telemetry-profile123 solace/backup: - broker: [myHost-backup:5671] + broker: myHost-backup:5671 auth: sasl_plain: username: otel diff --git a/receiver/solacereceiver/config.go b/receiver/solacereceiver/config.go index e8eaffa48894..2bdf2cd67a59 100644 --- a/receiver/solacereceiver/config.go +++ b/receiver/solacereceiver/config.go @@ -24,11 +24,12 @@ var ( errMissingXauth2Params = errors.New("missing xauth2 text auth params: Username, Bearer") errMissingFlowControl = errors.New("missing flow control configuration: DelayedRetry must be selected") errInvalidDelayedRetryDelay = errors.New("delayed_retry.delay must > 0") + errInvalidBroker = errors.New("exactly one broker must be specified") ) // Config defines configuration for Solace receiver. type Config struct { - // The list of solace brokers (default localhost:5671) + // The solace broker (default localhost:5671). It's a slice because of legacy reasons but it supports only one element. Broker []string `mapstructure:"broker"` // The name of the solace queue to consume from, it is required parameter @@ -57,6 +58,9 @@ func (cfg *Config) Validate() error { } else if cfg.Flow.DelayedRetry.Delay <= 0 { return errInvalidDelayedRetryDelay } + if len(cfg.Broker) != 1 { + return errInvalidBroker + } return nil } diff --git a/receiver/solacereceiver/config_test.go b/receiver/solacereceiver/config_test.go index e0169e79c27d..aa71d53cade9 100644 --- a/receiver/solacereceiver/config_test.go +++ b/receiver/solacereceiver/config_test.go @@ -51,6 +51,29 @@ func TestLoadConfig(t *testing.T) { }, }, }, + { + id: component.NewIDWithName(metadata.Type, "brokerString"), + expected: &Config{ + Broker: []string{"myHost:5671"}, + Auth: Authentication{ + PlainText: &SaslPlainTextConfig{ + Username: "otel", + Password: "otel01$", + }, + }, + Queue: "queue://#trace-profile123", + MaxUnacked: 1234, + TLS: configtls.ClientConfig{ + Insecure: false, + InsecureSkipVerify: false, + }, + Flow: FlowControl{ + DelayedRetry: &FlowControlDelayedRetry{ + Delay: 1 * time.Second, + }, + }, + }, + }, { id: component.NewIDWithName(metadata.Type, "noauth"), expectedErr: errMissingAuthDetails, @@ -115,6 +138,18 @@ func TestConfigValidateInvalidFlowControlDelayedRetryDelay(t *testing.T) { assert.Equal(t, errInvalidDelayedRetryDelay, err) } +func TestConfigValidateBroker(t *testing.T) { + cfg := createDefaultConfig().(*Config) + cfg.Queue = "someQueue" + cfg.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"} + cfg.Broker = []string{} + err := component.ValidateConfig(cfg) + assert.Equal(t, errInvalidBroker, err) + cfg.Broker = []string{"broker1:5671", "broker2:5671"} + err = component.ValidateConfig(cfg) + assert.Equal(t, errInvalidBroker, err) +} + func TestConfigValidateSuccess(t *testing.T) { successCases := map[string]func(*Config){ "With Plaintext Auth": func(c *Config) { diff --git a/receiver/solacereceiver/testdata/config.yaml b/receiver/solacereceiver/testdata/config.yaml index 3935d3d5aa4d..ac75dd388bde 100644 --- a/receiver/solacereceiver/testdata/config.yaml +++ b/receiver/solacereceiver/testdata/config.yaml @@ -10,6 +10,18 @@ solace/primary: delayed_retry: delay: 1s +solace/brokerString: + broker: myHost:5671 + auth: + sasl_plain: + username: otel + password: otel01$ + queue: queue://#trace-profile123 + max_unacknowledged: 1234 + flow_control: + delayed_retry: + delay: 1s + solace/backup: auth: sasl_xauth2: From 41676ecb990e9267762ea0b4511a796933ae0c22 Mon Sep 17 00:00:00 2001 From: William Dumont Date: Fri, 15 Nov 2024 11:04:53 +0100 Subject: [PATCH 2/2] changelog --- .chloggen/update-broker-config.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .chloggen/update-broker-config.yaml diff --git a/.chloggen/update-broker-config.yaml b/.chloggen/update-broker-config.yaml new file mode 100644 index 000000000000..b3d7fcb7a085 --- /dev/null +++ b/.chloggen/update-broker-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: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: solacereceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Document the broker field as a string and add validation checks + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [36387] + +# (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: []