You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validate port from the collector config in the webhook (#4399)
* Validate portt from the collector config in the webhook
Signed-off-by: Pavol Loffay <[email protected]>
* Validate portt from the collector config in the webhook
Signed-off-by: Pavol Loffay <[email protected]>
* Validate portt from the collector config in the webhook
Signed-off-by: Pavol Loffay <[email protected]>
* chore: fix tests
Signed-off-by: Pavol Loffay <[email protected]>
---------
Signed-off-by: Pavol Loffay <[email protected]>
# 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: Validate collector ports from the config to ensure they are within the valid range (1-65535).
9
+
10
+
# One or more tracking issues related to the change
11
+
issues: [4399]
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: |
17
+
- This change adds validation for collector ports specified in the configuration file.
18
+
- Ports must be within the range of 1 to 65535; otherwise, an error will be raised during CR creation.
19
+
- This helps prevent misconfigurations that could lead to runtime errors.
returnwarnings, fmt.Errorf("the OpenTelemetry config is incorrect. The port numbers are invalid: %w", errPorts)
235
+
}
236
+
for_, p:=rangeports {
237
+
truncName:=naming.Truncate(p.Name, maxPortLen)
238
+
iftruncName!=p.Name {
239
+
warnings=append(warnings, fmt.Sprintf("the OpenTelemetry config port name '%s' exceeds the maximum length of 15 characters and has been truncated to '%s'", p.Name, truncName))
240
+
}
241
+
nameErrs:=validation.IsValidPortName(truncName)
242
+
numErrs:=validation.IsValidPortNum(int(p.Port))
243
+
iflen(nameErrs) >0||len(numErrs) >0 {
244
+
returnwarnings, fmt.Errorf("the OpenTelemetry config is incorrect. The port name '%s' errors: %s, num '%d' errors: %s", p.Name, nameErrs, p.Port, numErrs)
0 commit comments