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

Fix Issue-96 Add AIX Support #97

Merged
merged 1 commit into from
Mar 2, 2018
Merged

Conversation

TJM
Copy link

@TJM TJM commented Feb 22, 2018

This fixes Issue-96, providing AIX support. NOTE that we enabled module level hiera to provide OSFAMILY specific data. We also put in a basic workaround for the "reload" of automount. Currently, at least on AIX, the service provider ignores the custom restart command.

NOTE: I did my best on the tests. I was not able to use PDK to validate the tests because your gemfile has binary requirements, which I cannot compile on my "work" computer. Let me know if they need fixed.

Thanks in advance,
Tommy

@bastelfreak
Copy link
Member

Hi @TJM, thanks for the PR. You can click on the travis link, it will show you all issues that the testsuite found.

@TJM
Copy link
Author

TJM commented Feb 23, 2018

Will fix stuff tomorrow, thanks

@TJM
Copy link
Author

TJM commented Feb 23, 2018

Hi there,

I think I may need some rspec help. https://travis-ci.org/voxpupuli/puppet-autofs/jobs/345296736

I know why this test is failing, because I added the "correct" filename for /etc/auto_master on Solaris. This brings up two issues for me.

  1. Why did I not get the same failure for AIX? (maybe I am missing where to specify that AIX should be tested)
  2. Sometimes, certain os's, such as AIX and Solaris will have a different filename or different file ownership for certrain resources. What is customarily the way to handle differences like that in rspec? Also, in AIX the file will have different group ownership (root:system). I am trying to add it in the most efficient/effective way.

I am researching, but any pointers in the right direction are appreciated ;)
Thanks in advance,
Tommy

@TJM
Copy link
Author

TJM commented Feb 23, 2018

That was kinda painful... sorry about all the noise. It is still not testing AIX. I am not sure why, as I think I updated metadata.json correctly (its lint is not balking). I am guessing its just soo obscure that its not in the factdb. I have done some testing on live systems and I think its good.

@bastelfreak
Copy link
Member

I haven't digged through the travis output, but I think it emulates facter 2.5 or 2.4. Facts come from https://github.com/camptocamp/facterdb/tree/master/facts/2.5. Do you have access to an AIX box and can provide those facts? The procedure is described in the README.md

@@ -0,0 +1,9 @@
version: 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hiera 5 \o/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I just couldn't bring myself to do the params.pp thing. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's totally fine.

Variant[String, Array[String]] $package_name,
Optional[String] $package_source,
Enum[ 'stopped', 'running' ] $service_ensure,
Boolean $service_enable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more datatypes \o/

# @param service_name Determine the name of the service for cross platform compatibility
# @param auto_master_map Filename of the auto.master map for cross platform compatiblity
# @param map_file_owner owner of the automount map files for cross platform compatiblity
# @param map_file_group group of the automount map files for cross platform compatiblity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puppet-strings \o/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye, I did not generate the docs, I assume that is part of the release process?

Copy link
Member

@dhollinger dhollinger Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings generation are a part of the release process, yes


exec { 'automount':
path => '/sbin:/usr/sbin',
command => 'automount -v',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do? Is this always needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tells the automount (daemon) to reload its config, without restarting (which causes automount to attempt to unmount all of its mounted filesystems).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we do a notify to the service? CC: @dhollinger

Copy link
Author

@TJM TJM Feb 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puppet seems pretty intent on restarting it on AIX at least, potentially other OS's as well, it doesn't seem to handle the concept of a "soft" reload.

On AIX It makes a decision on whether to send it a "signal" (HUP?) based on lsssrc -Ss automountd output. Basically the 11th(?) flag is a -S vs a -K, see provider for gory details. Long story short, its out of our hands. The src provider (used by AIX) seems to ignore the "restart" command offered as a parameter to the service resource as well, we tried that. :)

I would bet based on "POSIX compliance" type reasoning that it also works for Linux, but I have not tested. (see my reply, this does not work in Linux)

On a side note, I talked about this in #puppet on Puppet Community Slack, and someone else (Richard Lawson) had to come up with a similar workaround.

I did not get a chance to test on Solaris, but from what I recall that is also the correct way to "notify" automount to refresh its auto_master file.

This is ugly, but the best thing I could come up with that actually works without restarting the daemon.

Copy link
Author

@TJM TJM Feb 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRAP: I just tested on Linux and because there is not an "automountd" it thinks you are trying to start the daemon again. Obviously this won't work as is... let me think on it and get back to you.

FWIW, Linux suffers the same problem. It uses "restart" (which is a stop and start) vs a "reload" (which is a HUP)

  • CentOS 6
Info: Concat[/etc/auto.master]: Scheduling refresh of Service[autofs]
Debug: Executing: '/sbin/service autofs status'
Debug: Executing: '/sbin/chkconfig autofs'
Debug: Executing: '/sbin/service autofs status'
Debug: Executing: '/sbin/service autofs restart'
Notice: /Stage[main]/Autofs::Service/Service[autofs]: Triggered 'refresh' from 1 event
  • CentOS 7
Info: Concat[/etc/auto.master]: Scheduling refresh of Service[autofs]
Debug: Executing: '/bin/systemctl is-active autofs'
Debug: Executing: '/bin/systemctl is-enabled autofs'
Debug: Executing: '/bin/systemctl is-active autofs'
Debug: Executing: '/bin/systemctl restart autofs'
Notice: /Stage[main]/Autofs::Service/Service[autofs]: Triggered 'refresh' from 1 event

Looks like I am going to have to have a @param reload_command, but making that work will probably require %{facts.os.release.major} unless I play real fast and loose with something like pkill -HUP automount :)

@@ -29,7 +43,7 @@
is_expected.to contain_concat('/etc/auto.home').with(
'ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'group' => group.to_s,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the .to_s isn't needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, I wouldn't think so, given that I assigned it as 'groupname', but I "borrowed" that idea from the puppetlabs-ntp spec tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove it and test if it works? IMO that isn't needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works without the .to_s

@TJM TJM changed the title Fix Issue-96 Add AIX Suport WIP: Fix Issue-96 Add AIX Suport Feb 24, 2018
@TJM
Copy link
Author

TJM commented Feb 24, 2018

RE: AIX Facts.... Their readme also says it "supports" AIX, perhaps it used to? I will have to copy the puppet facts output over and "sanitize" it a bit, but I will send them a PR next week.

String $auto_master_map,
String $map_file_owner,
String $map_file_group,
String $reload_command,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TJM Is the plan here to supersede the Service resource in the resource abstraction layer?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see below

manifests/map.pp Outdated
@@ -38,14 +38,15 @@

unless $::autofs::package_ensure == 'absent' {
Concat {
notify => Service['autofs'],
before => Service[$autofs::service_name],
notify => Exec['automount-reload'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an AIX/Solaris requirement only or is it global to autofs?

If so, would it be better to build this into a native type/provider? (I'm not a fan of Exec, I've had too many issues with them not working or executing when they shouldn't)

Copy link
Author

@TJM TJM Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is global to autofs. If you use the puppet "service" resource, the "notify" will restart (stop then start) automount(d). This causes automount to attempt to unmount all automounted filesystems for a simple configuration change, which is not desirable. The EL6 init script and EL7 systemd svc have a reload option which send a HUP to the automount PID to tell automount to re-read its auto.master map without completely restarting.

I tried to use the restart command parameter, but the AIX service provider (src) completely ignores it, and just runs a stop/start operation anyhow (see my previous comments about lssrc). I think the best thing would be https://tickets.puppetlabs.com/browse/PUP-1054 .. but until then, a refreshonly exec was the best workaround I could think of. The type/provider mechanism would be a more proper/permanent fix, but I don't really know enough ruby to go down that path. It does occur to me that you might be able to "sub-class" (?) the service provider and just provide the reload capability, but if you go to that much trouble, it should probably be its own module? (or a PR to PUP-1054)

Unfortunately I already combined my commits, or you could cherrypick around it ... I guess I could split the "better reload" capability off to a different branch as it is technically NOT related to AIX.

Admittedly, using pkill was just a shot from the hip, as per my previous comments. While it worked in my test systems, it did not pass tests, likely due to the lack of pkill in the most minimal builds.

~tommy

@bastelfreak
Copy link
Member

I'm fine with this, thanks for the work @TJM. @dhollinger can you review as well?

@alexjfisher alexjfisher changed the title WIP: Fix Issue-96 Add AIX Suport WIP: Fix Issue-96 Add AIX Support Feb 27, 2018
autofs::maps: {}
autofs::package_ensure: installed
autofs::package_name: autofs
autofs::package_source: null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is null correct? I thought ~ was used for setting undef via hiera.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null works correctly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming. I struggled to find a definitive answer on any difference between using null or ~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this while reviewing, thanks for catching this @alexjfisher. Should we switch to ~ here? As far as I know, ~ is the best practice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're equivalent: http://www.yaml.org/refcard.html

(Or you can nerd out and read the spec itself!)

@bastelfreak
Copy link
Member

@TJM can you please rebase?

@TJM TJM changed the title WIP: Fix Issue-96 Add AIX Support Fix Issue-96 Add AIX Support Feb 28, 2018
@TJM
Copy link
Author

TJM commented Feb 28, 2018

meh, now there are failing tests, I will --amend when I figure them out

@TJM
Copy link
Author

TJM commented Mar 1, 2018

Do you need anything else from me on this?

Copy link
Member

@dhollinger dhollinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Though I want one more set of eyes on it as well.

@alexjfisher or @bastelfreak can you take a second look, make sure I didn't miss anything?

@dhollinger dhollinger merged commit cd03a7e into voxpupuli:master Mar 2, 2018
@dhollinger dhollinger mentioned this pull request Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants