Skip to content

Commit 12fdd37

Browse files
authored
Merge branch '2.0.0' into 2.0.0_release_prep
2 parents 634b350 + 2eafbbc commit 12fdd37

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Version 2.2.0
1+
# Version 2.0.0
22

33
Various fixes for github issues
44
- 193
@@ -129,4 +129,4 @@ Forked for garethr/docker v5.3.0
129129
Added support for:
130130
- Docker services within a swarm cluster
131131
- Swarm mode
132-
- Docker secrets
132+
- Docker secrets

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,15 @@ docker::run { 'helloworld':
386386
}
387387
```
388388

389-
To enable the restart of an unhealthy container add the following code to the manifest file.
389+
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.
390390

391391
```puppet
392392
docker::run { 'helloworld':
393393
image => 'base',
394394
command => 'command',
395-
health_check_command => '<command_to_execute_to_check_your_containers_health>',
395+
health_check_cmd => '<command_to_execute_to_check_your_containers_health>',
396396
restart_on_unhealthy => true,
397+
health_check_interval => '<time between running docker healthcheck>',
397398
```
398399

399400
To run command on Windows 2016 requires the `restart` parameter to be set:

lib/puppet/parser/functions/docker_run_flags.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ module Puppet::Parser::Functions
4747
end
4848

4949
if opts['health_check_cmd'].to_s != 'undef'
50-
flags << "--health-cmd #{opts['health_check_cmd']}"
50+
flags << "--health-cmd='#{opts['health_check_cmd']}'"
51+
end
52+
53+
if opts['health_check_interval'].to_s != 'undef'
54+
flags << "--health-interval=#{opts['health_check_interval']}s"
5155
end
5256

5357
if opts['tty']

manifests/run.pp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
# (optional) Specifies the command to execute to check that the container is healthy using the docker health check functionality.
5353
# Default: undef
5454
#
55+
# [*health_check_interval*]
56+
# (optional) Specifies the interval that the health check command will execute in seconds.
57+
# Default: undef
58+
#
5559
# [*restart_on_unhealthy*]
5660
# (optional) Checks the health status of Docker container and if it is unhealthy the service will be restarted.
5761
# The health_check_cmd parameter must be set to true to use this functionality.
@@ -121,6 +125,7 @@
121125
Optional[Boolean] $read_only = false,
122126
Optional[String] $health_check_cmd = undef,
123127
Optional[Boolean] $restart_on_unhealthy = false,
128+
Optional[Integer] $health_check_interval = undef,
124129
) {
125130
include docker::params
126131
if ($socket_connect != []) {
@@ -193,6 +198,7 @@
193198
read_only => $read_only,
194199
health_check_cmd => $health_check_cmd,
195200
restart_on_unhealthy => $restart_on_unhealthy,
201+
health_check_interval => $health_check_interval,
196202
})
197203

198204
$sanitised_title = regsubst($title, '[^0-9A-Za-z.\-_]', '-', 'G')
@@ -449,17 +455,17 @@
449455
path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'],
450456
command => 'systemctl daemon-reload',
451457
refreshonly => true,
452-
require => File[$initscript],
453-
subscribe => File[$initscript],
458+
require => [File[$initscript],File[$runscript]],
459+
subscribe => [File[$initscript],File[$runscript]]
454460
}
455461
Exec["docker-${sanitised_title}-systemd-reload"] -> Service<| title == "${service_prefix}${sanitised_title}" |>
456462
}
457463

458464
if $restart_service {
459-
File[$initscript] ~> Service<| title == "${service_prefix}${sanitised_title}" |>
465+
[File[$initscript],File[$runscript]] ~> Service<| title == "${service_prefix}${sanitised_title}" |>
460466
}
461467
else {
462-
File[$initscript] -> Service<| title == "${service_prefix}${sanitised_title}" |>
468+
[File[$initscript],File[$runscript]] -> Service<| title == "${service_prefix}${sanitised_title}" |>
463469
}
464470
}
465471
}

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": [
1111
{"name":"puppetlabs/stdlib","version_requirement":">= 4.24.0"},
1212
{"name":"puppetlabs/apt","version_requirement":">= 4.4.1"},
13-
{"name":"puppetlabs/translate","version_requirement":">= 0.0.1 < 1.1.0"},
13+
{"name":"puppetlabs/translate","version_requirement":">= 0.0.1 <=1.1.0"},
1414
{"name":"puppetlabs/powershell","version_requirement":">= 2.1.4"},
1515
{"name":"puppetlabs/reboot","version_requirement":">= 2.0.0"}
1616
],

spec/defines/run_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@
132132
'command' => 'command',
133133
'image' => 'base',
134134
'health_check_cmd' => 'pwd',
135-
'restart_on_unhealthy' => true
135+
'restart_on_unhealthy' => true,
136+
'health_check_interval' => 60,
136137
}}
137138
if (systemd)
138139
it { should contain_file(initscript).with_content(/ExecStop=-\/usr\/bin\/docker stop --time=0 /) }

0 commit comments

Comments
 (0)