Skip to content

Commit b984794

Browse files
jynolencodebotenatoulmeChrsMark
authored
fix: cloudwatch control message makes consumelogs crash with sigsegv (#44231)
#### Description With following config: ``` receivers: awss3: s3downloader: region: "ca-central-1" s3_bucket: "<redacted>" encodings: - extension: awslogs_encoding/cloudwatch sqs: queue_url: "<redacted>" region: "ca-central-1" exporters: nop: service: extensions: [awslogs_encoding/cloudwatch] pipelines: logs/aws: receivers: [awss3] processors: [] exporters: [ nop ] extensions: awslogs_encoding/cloudwatch: format: cloudwatch ``` And this kind of message in the bucket (gzip in bucket btw) ``` { "messageType": "CONTROL_MESSAGE", "owner": "CloudwatchLogs", "logGroup": "", "logStream": "", "subscriptionFilters": [], "logEvents": [ { "id": "", "timestamp": 1763029869851, "message": "CWL CONTROL MESSAGE: Checking health of destination Firehose." } ] }{ "messageType": "DATA_MESSAGE", "owner": "0000000000000", "logGroup": "/this/is/a/log/group", "logStream": "this-is-a-log-stream", "subscriptionFilters": [ "EksToS3" ], "logEvents": [ { "id": "000000000000011111111111111111122222222222222222233333333333333333", "timestamp": 1763029869386, "message": "dummy message", "extractedFields": { "@aws.account": "0000000000000", "@aws.region": "ca-central-1" } } ] } ``` I got the following issue ``` [signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0xbbac4a] goroutine 125 [running]: go.opentelemetry.io/collector/pdata/internal.(*State).IsReadOnly(...) go.opentelemetry.io/collector/[email protected]/internal/state.go:53 go.opentelemetry.io/collector/pdata/plog.Logs.IsReadOnly(...) go.opentelemetry.io/collector/[email protected]/plog/logs.go:13 go.opentelemetry.io/collector/internal/fanoutconsumer.(*logsConsumer).ConsumeLogs(0xc000645260, {0x2d23670, 0xc0005760a0}, {0x0?, 0x0?}) go.opentelemetry.io/collector/internal/[email protected]/logs.go:61 +0x1ea github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver.(*logsReceiver).processReceivedData(0xc000446590, {0x2d23670, 0xc0005760a0}, 0xc000280a20, {0xc0001d7860, 0x57}, {0xc001578000, 0x9b07c, 0xac000}) github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/receiver.go:262 +0x6c7 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver.(*awss3Receiver).receiveBytes(0xc000280a20, {0x2d23670, 0xc0005760a0}, {0xc0001d7860, 0x57}, {0xc001578000, 0x9b07c, 0xac000}) github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/receiver.go:138 +0x253 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver.(*s3SQSNotificationReader).readAll(0xc000572ae0, {0x2d23670, 0xc0005760a0}, {0x2d70d98?, 0x23233c0?}, 0xc000518000) github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/s3sqsreader.go:208 +0x1939 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver.(*awss3Receiver).Start.func1() github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/receiver.go:106 +0x8a created by github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver.(*awss3Receiver).Start in goroutine 1 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/receiver.go:105 +0x14c ``` Changing to proper logs initialization fix the issue --------- Signed-off-by: Jean-Yves NOLEN <[email protected]> Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Antoine Toulme <[email protected]> Co-authored-by: Christos Markou <[email protected]>
1 parent 6968a70 commit b984794

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'bug_fix'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: extension/awslogs_encoding
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: address the SIGSEGV occurring when processing control_message messages.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [44231]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"messageType": "CONTROL_MESSAGE",
3+
"owner": "CloudwatchLogs",
4+
"logGroup": "log_group_name",
5+
"logStream": "log_stream_name",
6+
"subscriptionFilters":[
7+
"subscription_filter_name"
8+
],
9+
"logEvents": [
10+
{
11+
"id": "",
12+
"timestamp": 1763029869851,
13+
"message": "CWL CONTROL MESSAGE: Checking health of destination Firehose."
14+
}
15+
]
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
resourceLogs: []

extension/encoding/awslogsencodingextension/internal/unmarshaler/subscription-filter/unmarshaler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (f *subscriptionFilterUnmarshaler) UnmarshalAWSLogs(reader io.Reader) (plog
6868
}
6969

7070
if cwLog.MessageType == "CONTROL_MESSAGE" {
71-
return plog.Logs{}, nil
71+
return plog.NewLogs(), nil
7272
}
7373

7474
if err := validateLog(cwLog); err != nil {

extension/encoding/awslogsencodingextension/internal/unmarshaler/subscription-filter/unmarshaler_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ func TestUnmarshallCloudwatchLog_SubscriptionFilter(t *testing.T) {
117117
reader: readAndCompressLogFile(t, filesDirectory, "valid_cloudwatch_log.json"),
118118
logsExpectedFilename: "valid_cloudwatch_log_expected.yaml",
119119
},
120+
"valid_cloudwatch_log_control": {
121+
reader: readAndCompressLogFile(t, filesDirectory, "valid_cloudwatch_log_control.json"),
122+
logsExpectedFilename: "valid_cloudwatch_log_control_expected.yaml",
123+
},
120124
"invalid_cloudwatch_log": {
121125
reader: readAndCompressLogFile(t, filesDirectory, "invalid_cloudwatch_log.json"),
122126
expectedErr: "invalid cloudwatch log",

0 commit comments

Comments
 (0)