Skip to content

Commit

Permalink
Support FireLens configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kaorimatz committed Dec 5, 2019
1 parent 8463a95 commit 1f1fd36
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/hako/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ def depends_on
end
end

def firelens_configuration
if @definition.key?('firelens_configuration')
conf = @definition['firelens_configuration']
{
type: conf.fetch('type'),
options: conf.fetch('options', nil),
}
end
end

private

PROVIDERS_KEY = '$providers'
Expand Down
9 changes: 8 additions & 1 deletion lib/hako/schedulers/ecs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,12 @@ def describe_task_definition(family)
# @return [Hash]
def create_definition(name, container)
environment = container.env.map { |k, v| { name: k, value: v } }
user = container.user
# Set user to '0' if not specified, otherwise a new task definition is
# always registered because user is set to '0' on a firelens container.
# If a user other than root is specified on a firelens container,
# registering a task definition fails.
user ||= '0' if container.firelens_configuration
{
name: name,
image: container.image_tag,
Expand All @@ -645,14 +651,15 @@ def create_definition(name, container)
linux_parameters: container.linux_parameters,
depends_on: container.depends_on,
volumes_from: container.volumes_from,
user: container.user,
user: user,
log_configuration: container.log_configuration,
health_check: container.health_check,
ulimits: container.ulimits,
extra_hosts: container.extra_hosts,
readonly_root_filesystem: container.readonly_root_filesystem,
docker_security_options: container.docker_security_options,
system_controls: container.system_controls,
firelens_configuration: container.firelens_configuration,
}
end

Expand Down
8 changes: 8 additions & 0 deletions lib/hako/schedulers/ecs_definition_comparator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def definition_schema
struct.member(:readonly_root_filesystem, Schema::Nullable.new(Schema::Boolean.new))
struct.member(:docker_security_options, Schema::Nullable.new(Schema::UnorderedArray.new(Schema::String.new)))
struct.member(:system_controls, Schema::Nullable.new(system_controls_schema))
struct.member(:firelens_configuration, Schema::Nullable.new(firelens_configuration_schema))
end
end

Expand Down Expand Up @@ -182,6 +183,13 @@ def system_control_schema
struct.member(:value, Schema::String.new)
end
end

def firelens_configuration_schema
Schema::Structure.new.tap do |struct|
struct.member(:type, Schema::String.new)
struct.member(:options, Schema::Nullable.new(Schema::Table.new(Schema::String.new, Schema::String.new)))
end
end
end
end
end
1 change: 1 addition & 0 deletions spec/hako/schedulers/ecs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
readonly_root_filesystem: nil,
docker_security_options: nil,
system_controls: nil,
firelens_configuration: nil
}],
volumes: [],
requires_compatibilities: nil,
Expand Down

0 comments on commit 1f1fd36

Please sign in to comment.