Skip to content

Commit 20a320c

Browse files
authored
set default address for all parsed receivers (#3333)
1 parent 8eb13f1 commit 20a320c

File tree

7 files changed

+32
-15
lines changed

7 files changed

+32
-15
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: collector
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: set default address for all parsed receivers
9+
10+
# One or more tracking issues related to the change
11+
issues: [3126]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

internal/components/multi_endpoint.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ type MultiPortOption func(parser *MultiPortReceiver)
3838

3939
// MultiPortReceiver is a special parser for components with endpoints for each protocol.
4040
type MultiPortReceiver struct {
41-
name string
41+
name string
42+
defaultRecAddr string
4243

4344
addrMappings map[string]string
4445
portMappings map[string]*corev1.ServicePort
@@ -85,7 +86,7 @@ func (m *MultiPortReceiver) GetDefaultConfig(logger logr.Logger, config interfac
8586
if ec != nil {
8687
port = ec.GetPortNumOrDefault(logger, port)
8788
}
88-
var addr string
89+
addr := m.defaultRecAddr
8990
if defaultAddr, ok := m.addrMappings[protocol]; ok {
9091
addr = defaultAddr
9192
}
@@ -118,11 +119,11 @@ func (m *MultiPortReceiver) GetRBACRules(logr.Logger, interface{}) ([]rbacv1.Pol
118119
type MultiPortBuilder[ComponentConfigType any] []Builder[ComponentConfigType]
119120

120121
func NewMultiPortReceiverBuilder(name string) MultiPortBuilder[*MultiProtocolEndpointConfig] {
121-
return append(MultiPortBuilder[*MultiProtocolEndpointConfig]{}, NewBuilder[*MultiProtocolEndpointConfig]().WithName(name))
122+
return append(MultiPortBuilder[*MultiProtocolEndpointConfig]{}, NewBuilder[*MultiProtocolEndpointConfig]().WithName(name).WithDefaultRecAddress("0.0.0.0"))
122123
}
123124

124125
func NewProtocolBuilder(name string, port int32) Builder[*MultiProtocolEndpointConfig] {
125-
return NewBuilder[*MultiProtocolEndpointConfig]().WithName(name).WithPort(port)
126+
return NewBuilder[*MultiProtocolEndpointConfig]().WithName(name).WithPort(port).WithDefaultRecAddress("0.0.0.0")
126127
}
127128

128129
func (mp MultiPortBuilder[ComponentConfigType]) AddPortMapping(builder Builder[ComponentConfigType]) MultiPortBuilder[ComponentConfigType] {
@@ -134,10 +135,12 @@ func (mp MultiPortBuilder[ComponentConfigType]) Build() (*MultiPortReceiver, err
134135
return nil, fmt.Errorf("must provide at least one port mapping")
135136
}
136137

138+
mb := mp[0].MustBuild()
137139
multiReceiver := &MultiPortReceiver{
138-
name: mp[0].MustBuild().name,
139-
addrMappings: map[string]string{},
140-
portMappings: map[string]*corev1.ServicePort{},
140+
name: mb.name,
141+
defaultRecAddr: mb.settings.defaultRecAddr,
142+
addrMappings: map[string]string{},
143+
portMappings: map[string]*corev1.ServicePort{},
141144
}
142145
for _, bu := range mp[1:] {
143146
built, err := bu.Build()

internal/components/receivers/helpers.go

-2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ var (
5252
components.NewMultiPortReceiverBuilder("otlp").
5353
AddPortMapping(components.NewProtocolBuilder("grpc", 4317).
5454
WithAppProtocol(&components.GrpcProtocol).
55-
WithDefaultRecAddress("0.0.0.0").
5655
WithTargetPort(4317)).
5756
AddPortMapping(components.NewProtocolBuilder("http", 4318).
5857
WithAppProtocol(&components.HttpProtocol).
59-
WithDefaultRecAddress("0.0.0.0").
6058
WithTargetPort(4318)).
6159
MustBuild(),
6260
components.NewMultiPortReceiverBuilder("skywalking").

internal/components/single_endpoint.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ func internalParseSingleEndpoint(logger logr.Logger, name string, failSilently b
8484
}
8585

8686
func NewSinglePortParserBuilder(name string, port int32) Builder[*SingleEndpointConfig] {
87-
return NewBuilder[*SingleEndpointConfig]().WithPort(port).WithName(name).WithPortParser(ParseSingleEndpoint).WithDefaultsApplier(AddressDefaulter)
87+
return NewBuilder[*SingleEndpointConfig]().WithPort(port).WithName(name).WithPortParser(ParseSingleEndpoint).WithDefaultsApplier(AddressDefaulter).WithDefaultRecAddress("0.0.0.0")
8888
}
8989

9090
func NewSilentSinglePortParserBuilder(name string, port int32) Builder[*SingleEndpointConfig] {
91-
return NewBuilder[*SingleEndpointConfig]().WithPort(port).WithName(name).WithPortParser(ParseSingleEndpointSilent).WithDefaultsApplier(AddressDefaulter)
91+
return NewBuilder[*SingleEndpointConfig]().WithPort(port).WithName(name).WithPortParser(ParseSingleEndpointSilent).WithDefaultsApplier(AddressDefaulter).WithDefaultRecAddress("0.0.0.0")
9292
}
9393

9494
func AddressDefaulter(logger logr.Logger, defaultRecAddr string, port int32, config *SingleEndpointConfig) (map[string]interface{}, error) {

tests/e2e/smoke-targetallocator/00-assert.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data:
2929
jaeger:
3030
protocols:
3131
grpc:
32-
endpoint: :14250
32+
endpoint: 0.0.0.0:14250
3333
prometheus:
3434
config:
3535
global:
@@ -52,4 +52,4 @@ data:
5252
- jaeger
5353
kind: ConfigMap
5454
metadata:
55-
name: stateful-collector-a65c7bf4
55+
name: stateful-collector-57180221

tests/e2e/statefulset-features/00-assert.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
items:
2222
- key: collector.yaml
2323
path: collector.yaml
24-
name: stateful-collector-1e082e0e
24+
name: stateful-collector-4b08af22
2525
name: otc-internal
2626
- emptyDir: {}
2727
name: testvolume

tests/e2e/statefulset-features/01-assert.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
items:
2222
- key: collector.yaml
2323
path: collector.yaml
24-
name: stateful-collector-1e082e0e
24+
name: stateful-collector-4b08af22
2525
name: otc-internal
2626
- emptyDir: {}
2727
name: testvolume

0 commit comments

Comments
 (0)