-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add a command line argument to set the logConfiguration #731
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e38221b
Add a command line argument to set the logConfiguration
brianz e04a9f9
Add to gitignore for vim swap files
brianz 97ba13a
Updtes based on feedback
brianz 85d5c29
Bump to latest ECS AMI
brianz a332d1f
Add tags to Empire minions
brianz b8c9801
Move LogConfiguration construction to `cmd/empire`
brianz 458b338
Merge remote-tracking branch 'remind/master'
brianz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
build | ||
.env* | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,19 +78,27 @@ type Config struct { | |
|
||
// AWS configuration. | ||
AWS client.ConfigProvider | ||
|
||
// Log driver to use when starting ECS tasks. Maps to the --log-driver docker cli arg | ||
LogDriver string | ||
|
||
// Log options to use when starting ECS tasks. Maps to the --log-opt docker cli arg | ||
LogOpts []string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should probably do the Actually, maybe even just make this |
||
} | ||
|
||
// NewScheduler returns a new Scehduler implementation that: | ||
// | ||
// * Creates services with ECS. | ||
func NewScheduler(config Config) (*Scheduler, error) { | ||
c := ecsutil.NewClient(config.AWS) | ||
l := ecsutil.NewLogConfiguration(config.LogDriver, config.LogOpts) | ||
|
||
// Create the ECS Scheduler | ||
var pm ProcessManager = &ecsProcessManager{ | ||
cluster: config.Cluster, | ||
serviceRole: config.ServiceRole, | ||
ecs: c, | ||
cluster: config.Cluster, | ||
serviceRole: config.ServiceRole, | ||
ecs: c, | ||
logConfiguration: l, | ||
} | ||
|
||
return &Scheduler{ | ||
|
@@ -111,12 +119,14 @@ func NewLoadBalancedScheduler(config Config) (*Scheduler, error) { | |
} | ||
|
||
c := ecsutil.NewClient(config.AWS) | ||
l := ecsutil.NewLogConfiguration(config.LogDriver, config.LogOpts) | ||
|
||
// Create the ECS Scheduler | ||
var pm ProcessManager = &ecsProcessManager{ | ||
cluster: config.Cluster, | ||
serviceRole: config.ServiceRole, | ||
ecs: c, | ||
cluster: config.Cluster, | ||
serviceRole: config.ServiceRole, | ||
ecs: c, | ||
logConfiguration: l, | ||
} | ||
|
||
// Create the ELB Manager | ||
|
@@ -305,9 +315,10 @@ var _ ProcessManager = &ecsProcessManager{} | |
// ecsProcessManager is an implementation of the ProcessManager interface that | ||
// creates ECS services for Processes. | ||
type ecsProcessManager struct { | ||
cluster string | ||
serviceRole string | ||
ecs *ecsutil.Client | ||
cluster string | ||
serviceRole string | ||
ecs *ecsutil.Client | ||
logConfiguration *ecs.LogConfiguration | ||
} | ||
|
||
// CreateProcess creates an ECS service for the process. | ||
|
@@ -341,7 +352,7 @@ func (m *ecsProcessManager) Run(ctx context.Context, app *scheduler.App, process | |
|
||
// createTaskDefinition creates a Task Definition in ECS for the service. | ||
func (m *ecsProcessManager) createTaskDefinition(ctx context.Context, app *scheduler.App, process *scheduler.Process) (*ecs.TaskDefinition, error) { | ||
taskDef, err := taskDefinitionInput(process) | ||
taskDef, err := taskDefinitionInput(process, m.logConfiguration) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -479,7 +490,7 @@ func (m *ecsProcessManager) Scale(ctx context.Context, app string, process strin | |
|
||
// taskDefinitionInput returns an ecs.RegisterTaskDefinitionInput suitable for | ||
// creating a task definition from a Process. | ||
func taskDefinitionInput(p *scheduler.Process) (*ecs.RegisterTaskDefinitionInput, error) { | ||
func taskDefinitionInput(p *scheduler.Process, logConfiguration *ecs.LogConfiguration) (*ecs.RegisterTaskDefinitionInput, error) { | ||
args, err := shellwords.Parse(p.Command) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -517,15 +528,16 @@ func taskDefinitionInput(p *scheduler.Process) (*ecs.RegisterTaskDefinitionInput | |
Family: aws.String(p.Type), | ||
ContainerDefinitions: []*ecs.ContainerDefinition{ | ||
&ecs.ContainerDefinition{ | ||
Name: aws.String(p.Type), | ||
Cpu: aws.Int64(int64(p.CPUShares)), | ||
Command: command, | ||
Image: aws.String(p.Image.String()), | ||
Essential: aws.Bool(true), | ||
Memory: aws.Int64(int64(p.MemoryLimit / MB)), | ||
Environment: environment, | ||
PortMappings: ports, | ||
DockerLabels: labels, | ||
Name: aws.String(p.Type), | ||
Cpu: aws.Int64(int64(p.CPUShares)), | ||
Command: command, | ||
Image: aws.String(p.Image.String()), | ||
Essential: aws.Bool(true), | ||
Memory: aws.Int64(int64(p.MemoryLimit / MB)), | ||
Environment: environment, | ||
LogConfiguration: logConfiguration, | ||
PortMappings: ports, | ||
DockerLabels: labels, | ||
}, | ||
}, | ||
}, nil | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 give an example of the format you'd pass here? I'd assume
tag=foo,thing=bar
?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.
logopt
takes multiple arguments, which is exactly how it works withdocker run
:...results in: