Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start+Enable the lvmetad service on RHEL7 #52

Merged
merged 1 commit into from
May 1, 2015
Merged

Conversation

irvingpop
Copy link

the lvmetad service is required by default in RHEL7 but is not automatically started. This patch enables and starts the service on RHEL7.

fixes: #43

juliandunn added a commit that referenced this pull request May 1, 2015
Start+Enable the lvmetad service on RHEL7
@juliandunn juliandunn merged commit b3817e5 into master May 1, 2015
@irvingpop irvingpop deleted the rhel7_start_lvmetad branch May 12, 2015 21:43
@Shuliyey
Copy link

Hi

we get the below error with this fix

 amazon-ebs: ================================================================================
    amazon-ebs: Error executing action `enable` on resource 'service[lvm2-lvmetad]'
    amazon-ebs: ================================================================================
    amazon-ebs:
    amazon-ebs: Mixlib::ShellOut::ShellCommandFailed
    amazon-ebs: ------------------------------------
    amazon-ebs: Expected process to exit with [0], but received '1'
    amazon-ebs: ---- Begin output of false --system enable lvm2-lvmetad ----
    amazon-ebs: STDOUT:
    amazon-ebs: STDERR:
    amazon-ebs: ---- End output of false --system enable lvm2-lvmetad ----
    amazon-ebs: Ran false --system enable lvm2-lvmetad returned 1
    amazon-ebs:
    amazon-ebs: Resource Declaration:
    amazon-ebs: ---------------------
    amazon-ebs: # In /var/lib/chef-solo/cookbooks-0/lvm/recipes/default.rb
    amazon-ebs:
    amazon-ebs: 35:   service 'lvm2-lvmetad' do
    amazon-ebs: 36:     action [:enable, :start]
    amazon-ebs: 37:     provider Chef::Provider::Service::Systemd
    amazon-ebs: 38:     only_if '/sbin/lvm dumpconfig global/use_lvmetad | grep use_lvmetad=1'
    amazon-ebs: 39:   end
    amazon-ebs: 40: end
    amazon-ebs:
    amazon-ebs: Compiled Resource:
    amazon-ebs: ------------------
    amazon-ebs: # Declared in /var/lib/chef-solo/cookbooks-0/lvm/recipes/default.rb:35:in `from_file'
    amazon-ebs:
    amazon-ebs: service("lvm2-lvmetad") do
    amazon-ebs: provider Chef::Provider::Service::Systemd
    amazon-ebs: action [:enable, :start]
    amazon-ebs: supports {:restart=>nil, :reload=>nil, :status=>nil}
    amazon-ebs: retries 0
    amazon-ebs: retry_delay 2
    amazon-ebs: default_guard_interpreter :default
    amazon-ebs: service_name "lvm2-lvmetad"
    amazon-ebs: pattern "lvm2-lvmetad"
    amazon-ebs: declared_type :service
    amazon-ebs: cookbook_name :lvm
    amazon-ebs: recipe_name "default"
    amazon-ebs: only_if "/sbin/lvm dumpconfig global/use_lvmetad | grep use_lvmetad=1"
    amazon-ebs: end
    amazon-ebs:
    amazon-ebs: Platform:
    amazon-ebs: ---------
    amazon-ebs: x86_64-linux
    amazon-ebs:
    amazon-ebs:
    amazon-ebs: Running handlers:
    amazon-ebs: [2017-04-11T13:45:43+10:00] ERROR: Running exception handlers
    amazon-ebs: Running handlers complete
    amazon-ebs: [2017-04-11T13:45:43+10:00] ERROR: Exception handlers complete
    amazon-ebs: Chef Client failed. 15 resources updated in 50 seconds
    amazon-ebs: [2017-04-11T13:45:43+10:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
    amazon-ebs: [2017-04-11T13:45:43+10:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    amazon-ebs: [2017-04-11T13:45:43+10:00] ERROR: service[lvm2-lvmetad] (lvm::default line 35) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
    amazon-ebs: ---- Begin output of false --system enable lvm2-lvmetad ----
    amazon-ebs: STDOUT:
    amazon-ebs: STDERR:
    amazon-ebs: ---- End output of false --system enable lvm2-lvmetad ----
    amazon-ebs: Ran false --system enable lvm2-lvmetad returned 1
    amazon-ebs: [2017-04-11T13:45:43+10:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

the service command is not able to enable lvm2-lvmetad for some reason

@Shuliyey
Copy link

Shuliyey commented Apr 12, 2017

Ok from my investigation, I believe the base image is amazon linux

NAME="Amazon Linux AMI"
VERSION="2017.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.03"
PRETTY_NAME="Amazon Linux AMI 2017.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

which is recognised as a redhat family with +7 version

however amazon linux still use init.d instead of systemd, which caused the error, if my investigation is correct.

@Shuliyey
Copy link

I've removed the provider Chef::Provider::Service::Systemd line, and it worked, is it really necessary to specify the provider line for this to work with systemd

@Shuliyey
Copy link

Shuliyey commented Apr 12, 2017

Hi @irvingpop

according to this
chef/chef#4665

i believe amazon linux 2017 is classified as rhel with platform_version 2017

but amazon linux 2017 doesn't use Systemd

i believe we for the below change

+# Start+Enable the lvmetad service on RHEL7, it is required by default
 +# but not automatically started
 +if node['platform_family'] == 'rhel' && node['platform_version'].to_i >= 7
 +  service 'lvm2-lvmetad' do
 +    action [:enable, :start]
 +    provider Chef::Provider::Service::Systemd
 +    only_if '/sbin/lvm dumpconfig global/use_lvmetad | grep use_lvmetad=1'
 +  end
 +end

we need to either add a condition

if node['platform_family'] == 'rhel' && node['platform_version'].to_i >= 7 && node['platform'] != 'amazon'

or we remove the provider Chef::Provider::Service::Systemd line

@irvingpop
Copy link
Author

Thanks @Shuliyey you're right - my change didn't account for Amazon linux, my apologies. It was also done during a time period when Chef client didn't reliably detect RHEL7 as a systemd, but that was resolved a long time ago.

could you please open a pull request to change the behavior? I think both or your suggestions could be safely implemented at this point.

@irvingpop
Copy link
Author

Correction: it looks like a PR has already been submitted for that in #127

@Shuliyey
Copy link

Shuliyey commented Apr 18, 2017

thanks @irvingpop , sorry i didn't reply in time.

I can see the PR in #127 , i was wondering, do you think the best change for this is to

exclude the amazon linux, or actually removed the provider Chef::Provider::Service::Systemd specification

so

if node['platform_family'] == 'rhel' && node['platform_version'].to_i >= 7 && node['platform'] != 'amazon'

or remove

provider Chef::Provider::Service::Systemd

I've mentioned the above in #127, thx for referencing it ;)

@Shuliyey
Copy link

Shuliyey commented Apr 19, 2017

Hi @irvingpop

I've submitted my pull-request #128, i believe the kitchen test passed. I don't believe #127 is the correct change, it failed the test with the same error, i got for amazon linux 2017.

theoretically i even think, the check condition if node['platform_family'] == 'rhel' && node['platform_version'].to_i >= 7 could be removed.

Because i think the only_if /sbin/lvm dumpconfig global/use_lvmetad | grep use_lvmetad=1 is a more proper/strong check to identify whether lvm2-lvmetad is required for lvm to work. e.g suppose on a ubuntu instance it has the use_lvmetad=1, would lvm2-lvmetad be required for lvm to work on the particular ubuntu instance? I believe the answer is yes.

It's more on the level of lvm configuration that defines whether lvm2-lvmetad is required. After all different linux distro all comes from the same family, it's just how they customized their kernal/application that differed them from each other (and this is to satisify the different purpose each of them serves, some may require strong security such as alpine linux, some may need to satisfy the special needs of corporations, such as redhat/centos)

@Shuliyey
Copy link

just a note, i tried removing if node['platform_family'] == 'rhel' && node['platform_version'].to_i >= 7

it failed on ubuntu
https://travis-ci.org/chef-cookbooks/lvm/builds/223384356

with

     ChefSpec::Error::CommandNotStubbed:
       Executing a real command is disabled. Unregistered command:

not sure why it's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lvm commands don't work on RHEL7 until you start the lvm2-lvmetad service
4 participants