Skip to content

Commit f9bda67

Browse files
David HollingerDavid Hollinger
authored andcommitted
MODULES-4753 Remove redundant swap exec resources
The exec resources running swapon and swapoff in the lvm::logical_volume define type were running whenever a swap logical volume was created or updated. The logical_volume provider was also running these same commands on a swap resize. This caused a conflict where the puppet run would error out when the logical_volume provider attempted to run swapoff on a swap lvm that had already been unloaded from swap and the lvm would never be reloaded into swap.
1 parent 31febe1 commit f9bda67

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

manifests/logical_volume.pp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,13 @@
101101
}
102102

103103
if $createfs or $ensure != 'present' {
104-
if $fs_type == 'swap' {
105-
if $ensure == 'present' {
106-
exec { "swapon for '${mount_title}'":
107-
path => [ '/bin', '/usr/bin', '/sbin' ],
108-
command => "swapon ${lvm_device_path}",
109-
unless => "grep `readlink -f ${lvm_device_path}` /proc/swaps",
110-
subscribe => Mount[$mount_title],
111-
}
112-
} else {
113-
exec { "swapoff for '${mount_title}'":
114-
path => [ '/bin', '/usr/bin', '/sbin' ],
115-
command => "swapoff ${lvm_device_path}",
116-
onlyif => "grep `readlink -f ${lvm_device_path}` /proc/swaps",
117-
notify => Mount[$mount_title],
118-
}
119-
}
120-
} else {
121-
exec { "ensure mountpoint '${fixed_mountpath}' exists":
122-
path => [ '/bin', '/usr/bin' ],
123-
command => "mkdir -p ${fixed_mountpath}",
124-
unless => "test -d ${fixed_mountpath}",
125-
before => Mount[$mount_title],
126-
}
104+
exec { "ensure mountpoint '${fixed_mountpath}' exists":
105+
path => [ '/bin', '/usr/bin' ],
106+
command => "mkdir -p ${fixed_mountpath}",
107+
unless => "test -d ${fixed_mountpath}",
108+
before => Mount[$mount_title],
127109
}
110+
128111
mount { $mount_title:
129112
ensure => $mount_ensure,
130113
name => $fixed_mountpath,

spec/unit/classes/lvm_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,5 @@
111111
:pass => 0,
112112
:dump => 0
113113
}) }
114-
it { should contain_exec("swapon for '/dev/myvg/swap'") }
115-
it { should_not contain_exec("ensure mountpoint 'swap_/dev/myvg/swap' exists") }
116-
117-
it { should contain_exec("swapoff for '/dev/myvg/swap2'") }
118-
it { should_not contain_exec("ensure mountpoint 'swap_/dev/myvg/swap2' exists") }
119114
end
120115
end

0 commit comments

Comments
 (0)