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

Add Solaris support to ncm-cron. #201

Merged
merged 5 commits into from Jun 23, 2014
Merged

Add Solaris support to ncm-cron. #201

merged 5 commits into from Jun 23, 2014

Conversation

NZJourneyMan
Copy link
Contributor

This change involves:

  • Adding a new variable securitypath to identify where the
    cron.allow/deny files live
  • Added processing to share crontab files with users on Solaris. This is because Solaris uses an old version of cron.
  • Solaris specific cron tests.
  • Updated pan files for securitypath
  • Add noaction support
  • Fix unit test bug

The most interesting change involves the shared use of user crontabs. To
make this work ncm-cron uses the concept of separate file sections
within the crontab. The ncm section is identified by the use of the
tags NCM-CRON BEGIN:and NCM-CRON END:. Entries either side of these
section identifiers are not modified.

THE FOLLOWING DISCLAIMER APPLIES TO ALL SOFTWARE CODE
AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS
SOFTWARE:
THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE AND ANY WARRANTY OF NON-
INFRINGEMENT, ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS
ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT
DISCLAIMER AS WELL AS ANY OTHER LICENSE TERMS THAT MAY
APPLY.

This change involves:
o Adding a new variable securitypath to identify where the
cron.allow/deny files live
o Added processing to share crontab files with users on Solaris. This
is because Solaris uses an old version of cron.
o Solaris specific cron tests.
o Updated pan files for securitypath

The most interesting change involves the shared use of user crontabs. To
make this work ncm-cron uses the concept of separate file sections
within the crontab.  The ncm section is identified by the use of the
tags NCM-CRON BEGIN:and NCM-CRON END:. Entries either side of these
section identifiers are not modified.
Code called unlink directly which meant that it was not noaction safe.
Switched to using LC::Check::absence as it supports noaction.

Tidied up the code and moved some repetetive sections to their own
functions.
Switching unlink for LC::Check::absence exposed a long standing bug
where the unit tests were trying to delete files in /etc/cron.d but
silently failing. The module was correctly flagging up the failure via
using $self->error(...) however these errors are ignored by the unit
testing system.

LC::Check is not unit test safe so added mocked methods for
LC::Check::status and LC::Check::absence to the linux configure test.
@hpcugentbot
Copy link

Automatic reply from Jenkins: Can I test this?

@ned21
Copy link
Contributor

ned21 commented May 9, 2014

ok to test

Solaris cron ignores environment variables on the preceding line (linux
style).

Solaris does not check to see if the crontabs have been changed so the
cron daemon needs to be refreshed.

Fixed file permission problems with solaris crontabs
@jrha
Copy link
Member

jrha commented May 20, 2014

Can you clarify the difference between the terms of your disclaimer and those of the Apache license that the quattor codebase is maintained under?

@ned21
Copy link
Contributor

ned21 commented May 20, 2014

@jrha - the licence used by Quattor is considered to be an "equivalent disclaimer". Unfortunately we are still required to attach this disclaimer to every patch.

@jrha
Copy link
Member

jrha commented May 20, 2014

Ugh.

my $ncmStop = "###### NCM-CRON END:";
my $ncmMsg = "Do not edit lines from NCM-CRON BEGIN to NCM-CRON END";
my $ncmMsgEnd = "This comment intentionally left blank";
our $osname = $OSNAME; # 'our' is required for testing to override the os
Copy link
Member

Choose a reason for hiding this comment

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

Arent these good old constants?

@piojo-zz
Copy link
Member

After rereading this, can you please refactor the code into Linux-specific and Solaris-specific methods for all those blocks that start with

if ($osname eq 'solaris')

?

You can then call

$self->do_something(...);

and choose the versions at load time by doing:

use constant  FOO => ...;
if ($osname eq 'solaris') {
    *do_something = \&do_something_solaris;
    *do_something_else = \&do_something_else_solaris;
    ...
} else {
    *do_something = \&do_something_linux;
    *do_something_else = \&do_something_else_linux;
    ...
}

@piojo-zz
Copy link
Member

Or split it into two modules and use base the appropriate one, whichever you find easiest.

@jrha jrha added this to the 14.6 milestone May 21, 2014
@NZJourneyMan
Copy link
Contributor Author

This is policy question on how we are to structure multi os ncm components. One that I feel shouldn't be left up to chance.

I know Mark Banister discussed this for his spma changes for solaris. I'm pretty happy to do it what ever way, however I wonder at this early stage of multi os support if it wouldn't be wise to figure out how this should be done, rather than everyone doing it a slightly different way.

Puppet for example has the concept of "providers" that allows for an abstracted interface to resources that are handled under the hood by the os default (or selected) provider. Should we be introducing this concept here? Or is multi os support something that isn't that important to quattor so it can be handled on an ad-hoc basis?

I'll join the standup tomorrow to see if I can get a feel for some direction.

@piojo-zz
Copy link
Member

This is policy question on how we are to structure multi os ncm components. One that I feel shouldn't be left up to chance.

Indeed. I see three cases here:

  • The semantics are similar but the service and implementation have to be entirely different. Think of chkconfig/systemd/SMF. See below.
  • The involved platforms are very similar, but not exactly identical. Your work on ncm-cron seems to fit here, but feel free to move it one level up.
  • SPMA.

I know Mark Banister discussed this for his spma changes for solaris. I'm pretty happy to do it what ever way,

Yes, but SPMA is special enough not to consider it a role model.

Puppet for example has the concept of "providers" that allows for an abstracted interface to resources that are handled under the hove itod by the os default (or selected) provider. Should we be introducing this concept here?

We have something similar since the last release. You can write your own alternative Perl module for any component, and locate it in any path under /software/components/, by specifying the ncm-module option:

# Run metaconfig too inside the myblueelephant
path "/software/components/myblueelephant/ncm-module" = "metaconfig";
# Use an alternative implementation for managing services
"/software/components/chkconfig/ncm-module" = "systemd";

The only requirement is that the Perl code has to discover its configuration path by calling $self->prefix().

Or is multi os support something that isn't that important to quattor so it can be handled on an ad-hoc basis?

It is as important as users make it. It seems to be quite important for you, so we are putting more effort into it now.

jrha added a commit that referenced this pull request Jun 23, 2014
Add Solaris support to ncm-cron.
@jrha jrha merged commit 0e3c07d into quattor:master Jun 23, 2014
@jrha
Copy link
Member

jrha commented Jun 23, 2014

Merged for 14.6, we can argue about style and philosophy again later!

@NZJourneyMan
Copy link
Contributor Author

This is actually on my todo list, unfortunately it keeps on getting trumped by higher priority jobs. So when it gets done I will open another PR.

@NZJourneyMan NZJourneyMan deleted the solaris branch July 2, 2014 14:24
aka7 pushed a commit to aka7/configuration-modules-core that referenced this pull request Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants