Erich, I've not had a chance to look over the install_prereq code yet but one key point that we wanted to stress from a "sanity" system is that we "make NO changes".
The only thing that happens is you do a check and either SUCCEED, FAIL, or WARN. If anything tries to fix matters, then you could have cascading issues, etc. and that isn't the point of the system-sanity facility. Geoffroy added some info in the Wiki with a brief description & usage details. I didn't want you to think I was blowing your email off, just not had time to read the install_prereq code and follow up. --tjn _________________________________________________________________________ Thomas Naughton [EMAIL PROTECTED] Research Associate (865) 576-4184 On Wed, 19 Jul 2006, Erich Focht wrote: > Hi Thomas, > > your approach to the systemsanity check is fine and as this is one of the > prereqs I suggest you incorporate the call to system-sanity into > install_prereqs. As you certainly know, install_prereq can invoke shell > scripts. Besides it has already the possibility to do different things with > different distributions, so you won't need to code that into the sanity check > scripts. > > install_prereq currently won't check for the return code of the shell scripts > (or arbitrary programs) it calls, but for the sanity check it might make > sense to add this. > > I want to concentrate the prereqs handling into install_prereqs and get rid of > the spaghetti code inside wizard_prep, at least for the prereqs part. I hope > you can support me in this struggle. > > Another comment: you mentioned as a TODO on your checkin message: > >> >> * TODO: Get the OCA based sanity framework going for oscar specific items. >> > > I'm not sure whether you followed the previous discussions on this. A short > overview of arguments: > > - I see no reason why the "OSCAR specific sanity framework" should be in > OCA. It simply doesn't fit the purpose of OCA. > - install_prereqs is currently dealing with most of what a future "sanity > framework" would need to do. It deletes previously installed packages which > we don't want on the system and installs packages which we need as > prereqs. Besides, it is much simpler to configure for various > distros/architectures. > - The extension proposed in > https://svn.oscar.openclustergroup.org/trac/oscar/ticket/209 > would make install_prereqs fulfill completely the requirements for OSCAR > packages related sanity checking. > - The code in the current OCA/Sanity_Check/* does simply not deserve the > attribute "framework". A _framework_ has to be general and extensible. Here > is an example: > > sub check_prereqs > { > my $pqtv = `rpm -q --qf '%{VERSION}' perl-Qt | sed -ne > \"s/^\\([1-9]*\\)..*/\\1/p\"`; > oca_debug_subsection ("perl-qt version: $pqtv\n"); > if ( $pqtv && $pqtv >= 3 ) { > return 1; > } > if ( $pqtv && $pqtv < 3 ) { > oca_debug_subsection("Removing installed perl-Qt RPM because version is < > 3"); > if ( !system("rpm -e perl-Qt") ) { > return -1; > } > } > > return -1; > } > > > This is simply a hardcoded piece of code which is both hard to extend and > hard to maintain. Imagine adding some if branches for particular > distros... And some more packages you need to care about... > > Concluding: install_prereqs is doing the job right now and can be used as > sanity checking infrastructure. It requires two small extensions: > - checking of shell script return codes (in order to react properly to the > system sanity checks) > - version dependent package installation/deletion. > It is extensible, easy to (re)configure _without_ programming, thus requires > only one test for functionality, not a test after each extension. > > I will extend install_prereqs anyway, so if you agree with the approach I > think you can save some work. Of course, if changes in the design of > install_prereqs are needed, I'm open for that. > > Best regards, > Erich > > > > On Wednesday 19 July 2006 00:46, [EMAIL PROTECTED] wrote: >> Author: naughtont >> Date: 2006-07-18 18:46:20 -0400 (Tue, 18 Jul 2006) >> New Revision: 5181 >> >> Added: >> trunk/lib/OSCAR/SystemSanity.pm >> trunk/scripts/system-sanity >> trunk/scripts/system-sanity.d/ >> trunk/scripts/system-sanity.d/su-check.pl >> Log: >> + add a very basic system sanity tool as discussed by Geoffroy Vallee >> and I today. Note, this is for basic system related things and not >> really OSCAR specific things. >> >> Descr: "System Sanity", check various system related known issues >> that preceeds the OSCAR specific checks, i.e., must be root, >> must have SELinux disabled, etc. >> >> Semantics: The tool reads a directory of check scripts, which either >> succeed, fail, or warn -- printing this status info and a >> provided message. (see also: OSCAR::SystemCheck for details), >> >> + The OSCAR::SystemCheck is simply to provide constants to be used >> for consistency in all the checks. >> >> + See the initial example: su-check.pl >> >> * ASSUMPTION: that OSCAR_HOME has been defined!!!! >> >> * TODO: the hook to call this will need to go somewhere very early, >> like install_cluster. >> >> * TODO: Get the OCA based sanity framework going for oscar specific items. >> >> >> >> Added: trunk/lib/OSCAR/SystemSanity.pm >> =================================================================== >> --- trunk/lib/OSCAR/SystemSanity.pm 2006-07-18 19:39:06 UTC (rev 5180) >> +++ trunk/lib/OSCAR/SystemSanity.pm 2006-07-18 22:46:20 UTC (rev 5181) >> @@ -0,0 +1,28 @@ >> +package OSCAR::SystemSanity; >> +# $Id$ >> +# >> +# Copyright (c) 2006 Oak Ridge National Laboratory. >> +# All rights reserved. >> +# >> +# Semantics: The tool reads a directory of check scripts, which either >> +# success (0), failure (255), or warning (1..254), printing >> +# such info and having the respective return codes. >> +# >> +# NOTE: Due to a single unsigned byte used in process tables on >> +# many system, we are limited to process/shell return codes >> +# of 0..255. >> +# >> +# See also: $OSCAR_HOME/scripts/{system-sanity, system-sanity.d/} >> +# >> + >> +use constant { SUCCESS => 0, >> + WARNING => 1, # can be 1..254 >> + FAILURE => 255, >> + }; >> + >> +# NOTE: required so the @EXPORT (default exported to all) works ok >> [EMAIL PROTECTED] = qw(Exporter); >> + >> [EMAIL PROTECTED] = qw(SUCCESS WARNING FAILURE); >> + >> +1; >> >> Added: trunk/scripts/system-sanity >> =================================================================== >> --- trunk/scripts/system-sanity 2006-07-18 19:39:06 UTC (rev 5180) >> +++ trunk/scripts/system-sanity 2006-07-18 22:46:20 UTC (rev 5181) >> @@ -0,0 +1,104 @@ >> +#!/usr/bin/perl -w >> +# $Id$ >> +# >> +# Copyright (c) 2006 Oak Ridge National Laboratory. >> +# All rights reserved. >> +# >> +# >> +# Descr: "System Sanity", check various system related known issues >> +# that preceeds the OSCAR specific checks, i.e., must be root, >> +# must have SELinux disabled, etc. >> +# >> +# Semantics: The tool reads a directory of check scripts, which either >> +# succeed, fail, or warn printing this status info and a >> +# provided message. (see also: OSCAR::SystemCheck for details), >> +# >> + >> +use lib "$ENV{OSCAR_HOME}/lib"; >> +use OSCAR::SystemSanity; # Enumeration for constants >> +use Carp; >> + >> +my $system_check_dir = $ENV{OSCAR_HOME} . "/scripts/system-sanity.d"; >> + >> +if (! -d $system_check_dir ) { >> + croak "Error: Missing system-check.d/ directory - >> \'$system_check_dir\'"; >> +} >> + >> +my @files = get_check_files( $system_check_dir ); >> + >> +foreach my $file (@files) { >> + my $script = $system_check_dir . "/" . $file; >> + >> + if (! -x $script) { >> + print_rslt(FAILURE, "not executable \'$file\'"); >> + >> + } else { >> + my $rc = system($script); >> + $rc = $rc >> 8; # Shift to get actual return code >> + print_rslt($rc, $file); >> + } >> + >> +} >> + >> +exit(0); >> + >> + >> +########################################################################## >> +# Sub-rtns >> + >> + >> + >> +# Descr: uniform display of status info & msg from system-sanity check(s). >> +# Return: success (1) / error (undef) >> +sub print_rslt >> +{ >> + my $rc = shift; >> + my $msg = shift; >> + >> + if ( !defined($rc) ) { >> + print "Error: undefined rc value passed to " . (caller(0))[3] >> ."\n"; >> + return(undef); >> + } >> + >> + if ($rc == FAILURE) { >> + print "Failure: $msg\n"; >> + >> + } elsif ($rc == SUCCESS) { >> + print "Success: $msg\n"; >> + >> + } elsif ($rc >= WARNING && $rc < FAILURE) { >> + # XXX: Keep at end b/c warnings are 1..254 >> + print "Warning: $msg\n"; >> + >> + } else { >> + # Crazy catch all case? >> + print "Crazy case -- should never see this...!\n - $msg\n"; >> + } >> + >> + return(1); >> +} >> + >> + >> +# Descr: read all system-sanity check file(s) from provided directory >> +# Return: list of system-sanity check filenames >> +# >> +# NOTE: Not fully qualify path in returned file list so caller can >> +# easily get at check filenames. >> +# >> +sub get_check_files >> +{ >> + my $dir = shift; >> + >> + opendir(DIR, "$dir") or die "Error: $! - \'$dir\'"; >> + >> + # RegEx: ignore all files starting with a dot, >> + # e.g., ".", "..", ".foobar" >> + my @files = grep { !/^\./ } readdir(DIR); >> + >> + closedir(DIR); >> + >> + return(@files); >> +} >> + >> + >> +# vim:tabstop=4:shiftwidth=4:syntax=perl:textwidth=76 >> >> >> Property changes on: trunk/scripts/system-sanity >> ___________________________________________________________________ >> Name: svn:executable >> + * >> >> Added: trunk/scripts/system-sanity.d/su-check.pl >> =================================================================== >> --- trunk/scripts/system-sanity.d/su-check.pl 2006-07-18 19:39:06 UTC >> (rev 5180) >> +++ trunk/scripts/system-sanity.d/su-check.pl 2006-07-18 22:46:20 UTC >> (rev 5181) >> @@ -0,0 +1,29 @@ >> +#!/usr/bin/perl >> +# $Id$ >> +# >> +# Copyright (c) 2006 Oak Ridge National Laboratory. >> +# All rights reserved. >> + >> +use warnings; >> +use English '-no_match_vars'; >> +use lib "$ENV{OSCAR_HOME}/lib"; >> + >> +# NOTE: Use the predefined constants for consistency! >> +use OSCAR::SystemSanity; >> + >> +my $rc = FAILURE; >> + >> +if ( ($UID == 0) and ($ENV{USER} eq "root") ) { >> + $rc = SUCCESS; >> + >> +} else { >> + print " ----------------------------------------------\n"; >> + print " $0 \n"; >> + print " UID=(" . $UID . ") \t should be \'0\'\n"; >> + print " USER=(" . $ENV{USER} . ") \t should be \'root\'\n"; >> + print " ----------------------------------------------\n"; >> + >> + $rc = FAILURE; >> +} >> + >> +exit($rc); > > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Oscar-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/oscar-devel
