-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make container logs available #1
Conversation
providers/aws/fargate/cluster.go
Outdated
err = client.logs.GetLogEventsPages(&cloudwatchlogs.GetLogEventsInput{ | ||
Limit: aws.Int64(int64(tail)), | ||
LogGroupName: aws.String(c.cloudWatchLogGroupName), | ||
LogStreamName: describeResult.LogStreams[0].LogStreamName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be more then one log stream per container, but maybe we should guard this better?
81358d6
to
7fc9ff3
Compare
Configuring ECS to forward logs to CloudWatch required #3 in our case. |
providers/aws/fargate/cluster.go
Outdated
// Due to a issue in the aws-sdk last page is never true, but the we can stop | ||
// as soon as no further results are returned | ||
// See https://github.com/aws/aws-sdk-ruby/pull/730 | ||
return len(page.Events) > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed for the SDK aws/aws-sdk-go#1908
IMO log group should be optional. Logs should only be stored and retrievable if configured. |
7fc9ff3
to
ee96133
Compare
Make sense and changed to be optional. |
providers/aws/config.go
Outdated
@@ -38,6 +38,7 @@ const ( | |||
type providerConfig struct { | |||
Region string | |||
ClusterName string | |||
CloudWatchLogGroupName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move this new field to be between AssignPublicIPv4Address and PlatformVersion? I am trying to keep all networking related fields (subnets, SGs, public IP address) follow cluster name.
providers/aws/config.go
Outdated
@@ -130,6 +131,7 @@ func (p *FargateProvider) loadConfig(r io.Reader) error { | |||
p.securityGroups = config.SecurityGroups | |||
|
|||
p.clusterName = config.ClusterName | |||
p.cloudWatchLogGroupName = config.CloudWatchLogGroupName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Please move one line below, between publicIPv4Address and platformVersion.
providers/aws/fargate.toml
Outdated
@@ -14,6 +14,10 @@ Region = "us-east-1" | |||
# we recommend to create a dedicated Fargate cluster for each virtual-kubelet. | |||
ClusterName = "fargate1" | |||
|
|||
# AWS CloudWatch Log Group Name used to store container logs. Optional. | |||
# If omitted, no container logs will be stored. | |||
CloudWatchLogGroupName = "/ecs/virtual-kubelet-logs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Move so that this new block is between AssignPublicIPv4Address and PlatformVersion.
providers/aws/fargate/cluster.go
Outdated
@@ -31,6 +33,7 @@ type Cluster struct { | |||
arn string | |||
subnets []string | |||
securityGroups []string | |||
cloudWatchLogGroupName string | |||
assignPublicIPv4Address bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Move between publicIP and platformVersion.
providers/aws/fargate/cluster.go
Outdated
@@ -64,6 +67,7 @@ func NewCluster(config *ClusterConfig) (*Cluster, error) { | |||
nodeName: config.NodeName, | |||
subnets: config.Subnets, | |||
securityGroups: config.SecurityGroups, | |||
cloudWatchLogGroupName: config.CloudWatchLogGroupName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Move between publicIP and platformVersion.
providers/aws/provider.go
Outdated
@@ -30,6 +30,7 @@ type FargateProvider struct { | |||
cluster *fargate.Cluster | |||
clusterName string | |||
capacity capacity | |||
cloudWatchLogGroupName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Move between publicIP and platformVersion.
providers/aws/fargate/cluster.go
Outdated
@@ -19,6 +20,7 @@ type ClusterConfig struct { | |||
NodeName string | |||
Subnets []string | |||
SecurityGroups []string | |||
CloudWatchLogGroupName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Move between publicIP and platformVersion.
providers/aws/fargate/client.go
Outdated
region string | ||
svc *ecs.ECS | ||
api ecsiface.ECSAPI | ||
svcLogs *cloudwatchlogs.CloudWatchLogs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to have a separate svcLogs since we'll be only using the "logs" API interface. Can you remove it, unless there is a good reason to keep it? I know I have one "svc" for ECS above, but that was because I was testing something and I'll remove that later alsol
providers/aws/fargate/client.go
Outdated
svc *ecs.ECS | ||
api ecsiface.ECSAPI | ||
svcLogs *cloudwatchlogs.CloudWatchLogs | ||
logs cloudwatchlogsiface.CloudWatchLogsAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should call this "logsapi". Or "logsAPI" if go lint wants it uppercase.
providers/aws/fargate/client.go
Outdated
@@ -37,10 +41,12 @@ func newClient(region string) (*Client, error) { | |||
return nil, err | |||
} | |||
|
|||
// Create the Fargate service client. | |||
// Create the Fargate & Cloudwatch service client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding this to existing Fargate client block, can you please create a new block?
...
// Create the Fargate service client.
...
// Create the CloudWatch service client.
client.logsAPI = cloudwatchlogs.New(session)
1d6b5b7
to
cd3b06c
Compare
Store and retrieve container logs using Cloudwatch Logs
cd3b06c
to
9b243e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Store and retrieve container logs using Cloudwatch Logs.
Regarding the overall design, should creating and configuring an CloudWatch Log Group be required or should logs only be stored and retrievable if this is configured?