From b53caa829a209cdf8fc5c7601d37400dda76b8cf Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 18 Jul 2018 15:55:53 +1000 Subject: [PATCH 1/9] adding in quotes for healthchecks with spaces --- lib/puppet/parser/functions/docker_run_flags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/parser/functions/docker_run_flags.rb b/lib/puppet/parser/functions/docker_run_flags.rb index b0efff1f..b779c7ad 100644 --- a/lib/puppet/parser/functions/docker_run_flags.rb +++ b/lib/puppet/parser/functions/docker_run_flags.rb @@ -47,7 +47,7 @@ module Puppet::Parser::Functions end if opts['health_check_cmd'].to_s != 'undef' - flags << "--health-cmd #{opts['health_check_cmd']}" + flags << "--health-cmd '#{opts['health_check_cmd']}'" end if opts['tty'] From 8fb816cb1b3b06d6dfb64285445035a33851535b Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 18 Jul 2018 16:12:22 +1000 Subject: [PATCH 2/9] adding in = sign for assignment --- lib/puppet/parser/functions/docker_run_flags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/parser/functions/docker_run_flags.rb b/lib/puppet/parser/functions/docker_run_flags.rb index b779c7ad..5386e746 100644 --- a/lib/puppet/parser/functions/docker_run_flags.rb +++ b/lib/puppet/parser/functions/docker_run_flags.rb @@ -47,7 +47,7 @@ module Puppet::Parser::Functions end if opts['health_check_cmd'].to_s != 'undef' - flags << "--health-cmd '#{opts['health_check_cmd']}'" + flags << "--health-cmd='#{opts['health_check_cmd']}'" end if opts['tty'] From bb8665c7132f2aef92ec07cd8da3216e0264a570 Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 18 Jul 2018 17:39:47 +1000 Subject: [PATCH 3/9] fixes restarting containers with changes to run arguments --- manifests/run.pp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/manifests/run.pp b/manifests/run.pp index 1a57c5b5..ce863711 100755 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -52,6 +52,10 @@ # (optional) Specifies the command to execute to check that the container is healthy using the docker health check functionality. # Default: undef # +# [*health_check_interval*] +# (optional) Specifies the interval that the health check command will execute in seconds. +# Default: 30 seconds +# # [*restart_on_unhealthy*] # (optional) Checks the health status of Docker container and if it is unhealthy the service will be restarted. # The health_check_cmd parameter must be set to true to use this functionality. @@ -121,6 +125,7 @@ Optional[Boolean] $read_only = false, Optional[String] $health_check_cmd = undef, Optional[Boolean] $restart_on_unhealthy = false, + Optional[Integer] $health_check_interval = 30, ) { include docker::params if ($socket_connect != []) { @@ -193,6 +198,7 @@ read_only => $read_only, health_check_cmd => $health_check_cmd, restart_on_unhealthy => $restart_on_unhealthy, + health_check_interval => $health_check_interval, }) $sanitised_title = regsubst($title, '[^0-9A-Za-z.\-_]', '-', 'G') @@ -449,14 +455,14 @@ path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'], command => 'systemctl daemon-reload', refreshonly => true, - require => File[$initscript], - subscribe => File[$initscript], + require => [File[$initscript],File[$runscript]], + subscribe => [File[$initscript],File[$runscript]] } Exec["docker-${sanitised_title}-systemd-reload"] -> Service<| title == "${service_prefix}${sanitised_title}" |> } if $restart_service { - File[$initscript] ~> Service<| title == "${service_prefix}${sanitised_title}" |> + [File[$initscript],File[$runscript]] ~> Service<| title == "${service_prefix}${sanitised_title}" |> } else { File[$initscript] -> Service<| title == "${service_prefix}${sanitised_title}" |> From a3ab86f580277bb560069b132bb8e978b5dd0947 Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 18 Jul 2018 17:45:18 +1000 Subject: [PATCH 4/9] removing incorrect changes --- manifests/run.pp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/manifests/run.pp b/manifests/run.pp index ce863711..fdcbaf58 100755 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -52,10 +52,6 @@ # (optional) Specifies the command to execute to check that the container is healthy using the docker health check functionality. # Default: undef # -# [*health_check_interval*] -# (optional) Specifies the interval that the health check command will execute in seconds. -# Default: 30 seconds -# # [*restart_on_unhealthy*] # (optional) Checks the health status of Docker container and if it is unhealthy the service will be restarted. # The health_check_cmd parameter must be set to true to use this functionality. @@ -125,7 +121,6 @@ Optional[Boolean] $read_only = false, Optional[String] $health_check_cmd = undef, Optional[Boolean] $restart_on_unhealthy = false, - Optional[Integer] $health_check_interval = 30, ) { include docker::params if ($socket_connect != []) { @@ -198,7 +193,6 @@ read_only => $read_only, health_check_cmd => $health_check_cmd, restart_on_unhealthy => $restart_on_unhealthy, - health_check_interval => $health_check_interval, }) $sanitised_title = regsubst($title, '[^0-9A-Za-z.\-_]', '-', 'G') From 15b232e55cd5984cf329f46b3873f8003563bb96 Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 18 Jul 2018 17:52:46 +1000 Subject: [PATCH 5/9] adding in for non restart_service also --- manifests/run.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/run.pp b/manifests/run.pp index fdcbaf58..80b495e8 100755 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -459,7 +459,7 @@ [File[$initscript],File[$runscript]] ~> Service<| title == "${service_prefix}${sanitised_title}" |> } else { - File[$initscript] -> Service<| title == "${service_prefix}${sanitised_title}" |> + [File[$initscript],File[$runscript]] -> Service<| title == "${service_prefix}${sanitised_title}" |> } } } From 21abd8e67c454b6cc85f4bcb2cfe4418d90a88cb Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 18 Jul 2018 18:04:27 +1000 Subject: [PATCH 6/9] fixing lint error --- manifests/run.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/run.pp b/manifests/run.pp index 80b495e8..da583706 100755 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -459,7 +459,7 @@ [File[$initscript],File[$runscript]] ~> Service<| title == "${service_prefix}${sanitised_title}" |> } else { - [File[$initscript],File[$runscript]] -> Service<| title == "${service_prefix}${sanitised_title}" |> + [File[$initscript],File[$runscript]] -> Service<| title == "${service_prefix}${sanitised_title}" |> } } } From d34210ca6f4e3cdfc7ae6d34d1f9c5fad8913fba Mon Sep 17 00:00:00 2001 From: davejrt <2067825+davejrt@users.noreply.github.com> Date: Wed, 18 Jul 2018 19:03:28 +1000 Subject: [PATCH 7/9] Update metadata.json --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 0c48fde2..6e73c31d 100755 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 4.24.0"}, {"name":"puppetlabs/apt","version_requirement":">= 4.4.1"}, - {"name":"puppetlabs/translate","version_requirement":">= 0.0.1 < 1.1.0"}, + {"name":"puppetlabs/translate","version_requirement":">= 0.0.1 <=1.1.0"}, {"name":"puppetlabs/powershell","version_requirement":">= 2.1.4"}, {"name":"puppetlabs/reboot","version_requirement":">= 2.0.0"} ], From 995588b10508e69049204659b643d86235910e70 Mon Sep 17 00:00:00 2001 From: Mark Wilson Date: Tue, 17 Jul 2018 16:11:44 +0100 Subject: [PATCH 8/9] CLOUD-2018-Add-health-check-interval --- README.md | 5 +++-- lib/puppet/parser/functions/docker_run_flags.rb | 4 ++++ manifests/run.pp | 6 ++++++ spec/defines/run_spec.rb | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 154abdc8..b7c4d214 100755 --- a/README.md +++ b/README.md @@ -386,14 +386,15 @@ docker::run { 'helloworld': } ``` -To enable the restart of an unhealthy container add the following code to the manifest file. +To enable the restart of an unhealthy container add the following code to the manifest file.In order to set the health check interval time set the optional health_check_interval parameter, the default health check interval is 30 seconds. ```puppet docker::run { 'helloworld': image => 'base', command => 'command', - health_check_command => '', + health_check_cmd => '', restart_on_unhealthy => true, + health_check_interval => '