Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions e2e/awslogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"net/url"
"strings"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
Expand Down Expand Up @@ -279,6 +280,27 @@ var testAwslogs = func() {
err = validateTestLogsInAwslogs(cwClient, testAwslogsGroup, testAwslogsStream, []string{testLog})
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
ginkgo.It("should verify that a 256KiB+1byte log sent to the awslogs driver is split into two log events", func() {
testLogCmd := `"$(yes A | tr -d \"\\n\" | head -c 262145)"`
want1 := strings.Repeat("A", 256*1024-26)
want2 := strings.Repeat("A", 27)
args := map[string]string{
LogDriverTypeKey: AwslogsDriverName,
ContainerIDKey: TestContainerID,
ContainerNameKey: TestContainerName,
awslogsCredentialsEndpointKey: testAwslogsCredentialEndpoint,
awslogsRegionKey: testAwslogsRegion,
awslogsGroupKey: testAwslogsGroup,
awslogsStreamKey: nonExistentAwslogsStream,
awslogsEndpointKey: testAwslogsEndpoint,
ModeKey: "non-blocking",
}
creator := cio.BinaryIO(*Binary, args)
err := SendTestLogByContainerd(creator, testLogCmd)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
err = validateTestLogsInAwslogs(cwClient, testAwslogsGroup, nonExistentAwslogsStream, []string{want1, want2})
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
})
}

Expand Down
2 changes: 2 additions & 0 deletions e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (

// LogDriverTypeKey is the key of log driver type.
LogDriverTypeKey = "--log-driver"
// ModeKey is the key of log driver mode.
ModeKey = "--mode"
// AwslogsDriverName is the name of awslogs driver.
AwslogsDriverName = "awslogs"
// FluentdDriverName is the name of fluentd driver.
Expand Down
5 changes: 1 addition & 4 deletions logger/awslogs/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ const (
// The value of maximumBytesPerEvent is adopted from Docker. Reference:
// https://github.com/moby/moby/blob/19.03/daemon/logger/awslogs/cloudwatchlogs.go#L58
maximumBytesPerEvent = 262144 - perEventBytes

// The max size of CloudWatch events is 256kb.
defaultAwsBufSizeInBytes = 256 * 1024
)

// Args represents AWSlogs driver arguments.
Expand Down Expand Up @@ -110,7 +107,7 @@ func (la *LoggerArgs) RunLogDriver(ctx context.Context, config *logging.Config,
if la.globalArgs.Mode == logger.NonBlockingMode {
debug.SendEventsToLog(logger.DaemonName, "Starting log streaming for non-blocking mode awslogs driver",
debug.INFO, 0)
l = logger.NewBufferedLogger(l, defaultAwsBufSizeInBytes, la.globalArgs.MaxBufferSize, la.globalArgs.ContainerID)
l = logger.NewBufferedLogger(l, maximumBytesPerEvent, la.globalArgs.MaxBufferSize, la.globalArgs.ContainerID)
}

// Start awslogs driver
Expand Down
Loading