Skip to content

Commit

Permalink
Merge pull request #17603 from carbonin/add_ansible_container_timeout
Browse files Browse the repository at this point in the history
Give embedded ansible enough time to start in containers
  • Loading branch information
bdunne authored Jul 5, 2018
2 parents d9b0f6c + 572f295 commit efe1c66
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@
:web_image_tag: latest
:rabbitmq_image_name: rabbitmq
:rabbitmq_image_tag: 3
:setup_wait_seconds: 1200
:memcached_image_name: memcached
:memcached_image_tag: alpine
:container:
:image_name: manageiq/embedded-ansible
:image_tag: latest
:service_account: miq-privileged
:setup_wait_seconds: 1200
:ems:
# provider specific settings are nested here, but they are in the provider repos
# e.g.:
Expand Down
29 changes: 6 additions & 23 deletions lib/embedded_ansible/container_embedded_ansible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def start
create_ansible_service
create_ansible_deployment_config

loop do
settings.setup_wait_seconds.times do
break if alive?

_log.info("Waiting for Ansible container to respond")
Expand Down Expand Up @@ -77,30 +77,13 @@ def create_ansible_deployment_config
dc[:spec][:template][:spec][:serviceAccountName] = settings.service_account

container = dc[:spec][:template][:spec][:containers].first
container[:ports] = [{:containerPort => 443}, {:containerPort => 80}]
container[:livenessProbe] = liveness_probe
container[:readinessProbe] = readiness_probe
container[:env] = container_environment
container[:image] = image

container[:ports] = [{:containerPort => 443}, {:containerPort => 80}]
container[:env] = container_environment
container[:image] = image
container[:securityContext] = {:privileged => true}
end
end

def liveness_probe
{
:tcpSocket => {:port => 443},
:initialDelaySeconds => 480,
:timeoutSeconds => 3
}
end

def readiness_probe
{
:httpGet => {:path => "/", :port => 443, :scheme => "HTTPS"},
:initialDelaySeconds => 200,
:timeoutSeconds => 3
}
container.delete(:livenessProbe)
end
end

def container_environment
Expand Down
2 changes: 1 addition & 1 deletion lib/embedded_ansible/docker_embedded_ansible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def start
run_web_container
run_task_container

loop do
settings.setup_wait_seconds.times do
break if alive?

_log.info("Waiting for Ansible container to respond")
Expand Down

0 comments on commit efe1c66

Please sign in to comment.