Split docker mirror and debug configs
Use augeas to modify only parameters' dedicated configuration. Split mirror configs from debug configs. Overlapping those params may cause augeas errors and/or nschedule the docker service restarts for some cases, ending up with split brain state for the docker service run-time config vs changed docker-daemon.json config. Follows-up Ic5640061837b022f7175f0db0dc269f9a61e6023 Change-Id: I7932aa2e0eb096ea09255084783e577bb450e0cd Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
parent
dc43cae137
commit
7687333445
@ -169,8 +169,13 @@ class tripleo::profile::base::docker (
|
||||
$mirror_changes = [ 'rm dict/entry[. = "registry-mirrors"]', ]
|
||||
}
|
||||
|
||||
$debug_changes = ['set dict/entry[. = "debug"] "debug"',
|
||||
"set dict/entry[. = \"debug\"]/const \"${debug}\"",]
|
||||
if $debug {
|
||||
$debug_changes = [
|
||||
'set dict/entry[. = "debug"] "debug"',
|
||||
"set dict/entry[. = \"debug\"]/const \"${debug}\"",]
|
||||
} else {
|
||||
$debug_changes = [ 'rm dict/entry[. = "debug"]', ]
|
||||
}
|
||||
|
||||
file { '/etc/docker/daemon.json':
|
||||
ensure => 'present',
|
||||
@ -180,14 +185,24 @@ class tripleo::profile::base::docker (
|
||||
require => Package['docker']
|
||||
}
|
||||
|
||||
augeas { 'docker-daemon.json':
|
||||
augeas { 'docker-daemon.json-mirror':
|
||||
lens => 'Json.lns',
|
||||
incl => '/etc/docker/daemon.json',
|
||||
changes => concat($mirror_changes, $debug_changes),
|
||||
changes => $mirror_changes,
|
||||
subscribe => Package['docker'],
|
||||
notify => Service['docker'],
|
||||
require => File['/etc/docker/daemon.json'],
|
||||
}
|
||||
|
||||
augeas { 'docker-daemon.json-debug':
|
||||
lens => 'Json.lns',
|
||||
incl => '/etc/docker/daemon.json',
|
||||
changes => $debug_changes,
|
||||
subscribe => Package['docker'],
|
||||
notify => Service['docker'],
|
||||
require => File['/etc/docker/daemon.json'],
|
||||
}
|
||||
|
||||
if $configure_storage {
|
||||
if $storage_options == undef {
|
||||
fail('You must provide a $storage_options in order to configure storage')
|
||||
|
@ -85,11 +85,9 @@ describe 'tripleo::profile::base::docker' do
|
||||
it { is_expected.to contain_service('docker') }
|
||||
it { is_expected.to contain_file('/etc/systemd/system/docker.service.d/99-unset-mountflags.conf') }
|
||||
it {
|
||||
is_expected.to contain_augeas('docker-daemon.json').with_changes(
|
||||
is_expected.to contain_augeas('docker-daemon.json-mirror').with_changes(
|
||||
['set dict/entry[. = "registry-mirrors"] "registry-mirrors',
|
||||
"set dict/entry[. = \"registry-mirrors\"]/array/string \"http://foo/bar\"",
|
||||
'set dict/entry[. = "debug"] "debug"',
|
||||
"set dict/entry[. = \"debug\"]/const \"false\""])
|
||||
"set dict/entry[. = \"registry-mirrors\"]/array/string \"http://foo/bar\""])
|
||||
}
|
||||
end
|
||||
|
||||
@ -104,9 +102,8 @@ describe 'tripleo::profile::base::docker' do
|
||||
it { is_expected.to contain_service('docker') }
|
||||
it { is_expected.to contain_file('/etc/systemd/system/docker.service.d/99-unset-mountflags.conf') }
|
||||
it {
|
||||
is_expected.to contain_augeas('docker-daemon.json').with_changes(
|
||||
['rm dict/entry[. = "registry-mirrors"]',
|
||||
'set dict/entry[. = "debug"] "debug"',
|
||||
is_expected.to contain_augeas('docker-daemon.json-debug').with_changes(
|
||||
['set dict/entry[. = "debug"] "debug"',
|
||||
"set dict/entry[. = \"debug\"]/const \"true\""])
|
||||
}
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user